2011-09-28 44 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