2 RelativeLayouts in one layout

81 views Asked by At

I've decided to use 2 RelativeLayouts for my app, one Layout for one portion of child Views on the screen to the left, the other for child Views to go to the right.

The problem is I don't know how to lay them out in XML so that the middle white space isn't included when I inflate my Layout.

This is what I want.

When I use 1 RelativeLayout, the middle white space is filled with the RelativeLayout, and I can't touch anything behind it.

Thank you very much for reading.

1

There are 1 answers

0
prolink007 On BEST ANSWER

Do something similar to the following example.

This will create a LinearLayout with 2 RelativeLayouts using layout_weight to space the RelativeLayouts and then you can populate the RelativeLayouts with whatever you want.

The Buttons are just place holders for the example.

<?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>