2011-09-28 127 views
1

我们如何在Android中制作嵌入式布局?Android - 如何内联包装布局?

事情是这样的:

example http://oi51.tinypic.com/91bi3a.jpg

我试图用相对布局保证金的权利,但它们被分成两列,而不是包裹对方:

<RelativeLayout 
    android:id="@+id/Container" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout 
      android:id="@+id/Layout1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginRight="60sp"> 
      .... //something here 
    </RelativeLayout> 
    <RelativeLayout 
      android:id="@+id/Layout2" 
      android:layout_width="60sp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true"> 
      .... //something here 
    </RelativeLayout> 
</RelativeLayout> 

谢谢您的帮助。

回答

0

Layout2的宽度为60dp,而在layout1中,您将margin设置为60dp,以使它们看起来像两列如果要检查它将layout1的边距更改为30dp,您将看到包装效果 ,并且还将一些控件放入内部布局以便您可以看到该区域

+0

如果删除边距,则会在layer2上渲染layer1内容。我想这是因为android:layout_alignParentRight =“true”不会使layer2“浮动内联”,而是“浮动下划线”。 – markbse