【问题标题】:2 RelativeLayouts in one layout一个布局中有 2 个 RelativeLayouts
【发布时间】:2012-07-31 19:32:10
【问题描述】:

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

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

This is what I want.

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

非常感谢您的阅读。

【问题讨论】:

    标签: android events android-relativelayout behind


    【解决方案1】:

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

    这将创建一个LinearLayout 和 2 个RelativeLayouts,使用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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-11
      • 1970-01-01
      • 1970-01-01
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多