Android布局重量我是Android开发的新手,我有一个关于在线性布局中设置权重的问题。我正在尝试使用两个自定义按钮和自定义编辑文本创建一行。编辑文本应占用与其内容相同的空间,并且两个按钮应水平扩展以填充行中的其余可用空间。像这样...| [#Button++#] [#Button--#] [et] |经过几次尝试,这是我能得到的最接近的东西,尽管看起来过于复杂。| [Button] [Button] [###ET###] |<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:layout_weight="1"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
>
<RelativeLayout
android:id="@+id/btn_plus_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageButton
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/btn_plus"
android:background="@drawable/btn"
android:layout_centerInParent="true"
></ImageButton>
<TextView
android:textColor="#FAFAF4"
android:id="@+id/tv_dice_plus"
android:text="@string/tv_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
></TextView>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
>据我所知设置[android:layout_weight =“2”]为线性布局按住按钮应该使它们占用比编辑文本更多的空间,但它对我来说却相反,使它们都是一半大小。| [Btn] [Btn] [#####et#####] |我已经尝试了很多不同的组合,我甚至都记不住它们,但没有一个有效。
- 3 回答
- 0 关注
- 367 浏览
添加回答
举报
0/150
提交
取消