【发布时间】:2016-08-04 12:04:40
【问题描述】:
我正在尝试使用 RelativeLayout 将三个按钮并排放置在一行中。
这是放置在带有按钮组的线性布局内的相对布局
main.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CC8FD8D8"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="20px" >
</RelativeLayout>
</LinearLayout>
这些是在布局中找到的一组按钮
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/snap"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="@+id/shutterButton"
android:text="SNAP"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/up"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="@+id/Up"
android:text="xxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_action_borrow"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="@+id/xxxx"
android:text="xxxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="@+id/xxxx"
android:text="xxxx"></Button>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/xxxx"
android:textColor="#FFFFFF"
android:background="#00FFFFFF"
android:id="@+id/xxxx"
android:text="xxxx"></Button>
【问题讨论】:
-
这种类型使用
LinearLayouts -
我有 LinearLayouts 并且都垂直对齐
-
LinearLayout和orientation="horizontal"会非常简单。虽然如果你仍然想使用RelativeLayout使用android:layout_toEndOf和/或android:layout_toRightOf属性。 -
竖直放置但没有停在第三个按钮
-
“没有停在”是什么意思?