我需要把3个按钮放在 android 布局中。
需要实现:
- 这些按钮都要在一行上
- 每个按钮都应该占显示宽度的33,3%宽度
我使用一个表格和 stack布局,但是不知道如何设置设置宽度,请大家帮忙。
我需要把3个按钮放在 android 布局中。
需要实现:
我使用一个表格和 stack布局,但是不知道如何设置设置宽度,请大家帮忙。
使用一个 LinearLayout,然后给每个按钮设置属性:android:layout_weight="1",就会把按钮设置成相同的宽度。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dip"
android:orientation="horizontal" >
<Button
android:id="@+id/rvButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/rvButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<Button
android:id="@+id/rvButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
/>