2012-03-31 17 views
1
使用

我有一個RelativeLayout的有一個孩子爲<include another.xml>中的RelativeLayout

這樣root.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/root" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 
<include layout="@layout/another.xml"/> 
</RelativeLayout> 

我的問題是不的Android在 頂級榮譽的android:layout_alignParentRight="true"我的another.xml

another.xml是這樣的:

<RelativelLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/control_panel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:orientation="vertical"> 
</RelativeLayout> 

基本上,我想在所有的意見我another.xml是正確對準我的根。 我已經在上面嘗試過,但我的another.xml中的視圖左對齊到我的根。

謝謝。

回答

5

號你必須做這樣的事情,併爲本是唯一的LinearLayout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/root" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 


    <RelativelLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" > 
    <include layout="@layout/another.xml" /> 
    </RelativelLayout> 

</RelativeLayout><RelativeLayout> 

</RelativeLayout> 
+0

+1'orientation'。 – Ghost 2012-03-31 05:20:10