2012-07-31 61 views
0

我决定使用2 RelativeLayouts为我的应用程序,一个Layout为子部分Views在屏幕左侧,其他为子Views去右边。2 RelativeLayouts在一个布局

问题是我不知道如何将它们放在XML中,以便在我膨胀我的Layout时不包含中间空白区域。

This is what I want.

当我使用1 RelativeLayout,中间白色的空间充满了RelativeLayout,我不能触摸它背后的东西。

非常感谢您的阅读。

+1

发布您的布局xml – StenaviN 2012-07-31 19:45:20

回答

2

做类似于下面的例子。

这将创建一个使用layout_weight空间的RelativeLayouts,然后你可以填充任何你想要的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>