2012-02-18 27 views
0

我有以下佈局buttons.xml安卓:<include>覆蓋並不影響佈局

<?xml version="1.0" encoding="UTF-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/buttonsLayout" android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:screenOrientation="portrait"> 

    <ImageView android:id="@+id/imgLeftArrow" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" android:layout_marginLeft="@dimen/standard_margin" 
     android:contentDescription="@string/pic_arrow_left" 
     android:background="@drawable/arrow_left" /> 

    <ImageView android:id="@+id/imgUpArrow" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_centerHorizontal="true" 
     android:contentDescription="@string/pic_arrow_up" android:background="@drawable/arrow_up" /> 

    <ImageView android:id="@+id/imgRightArrow" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" android:layout_marginRight="@dimen/standard_margin" 
     android:contentDescription="@string/pic_arrow_right" 
     android:background="@drawable/arrow_right" /> 

</RelativeLayout> 

而且我有main.xml中的佈局:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/mainLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:screenOrientation="portrait" > 

    <include 
     android:layout_alignParentBottom="true" 
     layout="@layout/buttons" /> 

</RelativeLayout> 

正如你所看到的,我重寫buttons.xml佈局位於此底部。 但問題是,佈局顯示在頂部,而不是底部。 如果我在buttons.xml的RelativeLayout中直接設置這個屬性,它會顯示在底部。

什麼問題?根據Android文檔http://developer.android.com/resources/articles/layout-tricks-reuse.html我可以覆蓋包含的佈局的屬性。

+0

您所提供的鏈接斷開。請修復。 – toobsco42 2012-12-15 23:43:27

回答

1
<RelativeLayout android:id="@+id/belowlayout" 
     android:layout_marginBottom="2dp" 
     android:layout_width="wrap_content" android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"> 
     <include layout="@layout/mybottomlayout" /> 
    </RelativeLayout>