我正在设计一个布局,底部有 3 个按钮,彼此非常相邻。因为我也想在屏幕中间添加更多按钮,所以我正在做的是将整个屏幕设置为相对布局,并在底部添加 3 个按钮,我添加了一个线性布局来包含这 3 个按钮. 但是,它会卡住。该按钮不会在底部显示 3 个按钮。这是我的 xml 布局文件
<RelativeLayout 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" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Button1"
android:layout_weight="0.3" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Button2"
android:layout_weight="0.3"/>
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Button3"
android:layout_weight="0.3" />
</LinearLayout>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/linearLayout1"
android:layout_marginTop="16dp"
android:layout_toRightOf="@+id/linearLayout1"
android:text="Button" />
<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button4"
android:layout_alignParentRight="true"
android:layout_below="@+id/button4"
android:layout_marginTop="20dp"
android:text="Button" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/button5"
android:layout_marginTop="24dp"
android:text="Button" />
</RelativeLayout>