0

我决定将 2RelativeLayouts用于我的应用程序,一个用于左侧屏幕上的Layout一部分孩子,另一个用于右侧的孩子。ViewsViews

问题是我不知道如何在 XML 中布置它们,这样当我膨胀我的Layout.

这就是我要的。

当我使用 1RelativeLayout时,中间的空白被 填充RelativeLayout,我不能触摸它后面的任何东西。

非常感谢您的阅读。

4

1 回答 1

2

执行类似于以下示例的操作。

这将使用 2 创建一个用于LinearLayout分隔的,然后您可以使用任何您想要的填充。RelativeLayoutslayout_weightRelativeLayoutsRelativeLayouts

只是示例的Buttons占位符。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TEST1" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1" >

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TEST2" />
    </RelativeLayout>

</LinearLayout>
于 2012-07-31T19:48:36.517 回答