2012-03-31 37 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