我正在尝试使用 ActionBarSherlock 实现自定义标题栏。标题栏的左右边缘应该有两个按钮,中间应该有一个文本视图。textview 应该占据两个按钮之间的空间。
我试过设置layout_weight,但由于某种原因它根本没有效果。
这是我在 res/layout 中的自定义布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_left"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Left" />
<TextView
android:id="@+id/header"
android:layout_width="0dip"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_weight="4"
android:text="Header Text" />
<Button
android:id="@+id/btn_right"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Right" />
</LinearLayout>
现在所有元素都向左浮动,我不知道为什么,我做错了什么?