一个布局中有2个相对布局



我决定为我的应用程序使用两个RelativeLayouts,一个Layout用于屏幕左侧的子Views的一部分,另一个用于屏幕右侧的子Views

问题是我不知道如何在XML中对它们进行布局,这样当我膨胀Layout时就不会包括中间的空白。

这就是我想要的。

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

非常感谢您的阅读。

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

这将创建一个带有2个RelativeLayoutsLinearLayout,使用layout_weightRelativeLayouts隔开,然后您可以用您想要的任何内容填充RelativeLayouts

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>

最新更新