android中的RelativeLayout优于另一个RelativeLayout

android中的RelativeLayout优于另一个RelativeLayout,android,xml,android-layout,Android,Xml,Android Layout,我在我的应用程序上实现了一个viewpager。在我所有的片段中,我有circlepageindicator、页眉和页脚。我的主要xml文件是: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/com.exam

我在我的应用程序上实现了一个viewpager。在我所有的片段中,我有circlepageindicator、页眉和页脚。我的主要xml文件是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.example.app"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<!-- Header aligned to top -->

<include layout="@layout/header" />

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.viewpagerindicator.CirclePageIndicator
        android:id="@+id/indicator"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="33dp"
        app:radius="4dp"
        app:fillColor="#00CCFF"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:padding="10dip" />
</RelativeLayout>

<!-- Footer aligned to bottom -->
<include layout="@layout/footer" />

</RelativeLayout>
My header.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header"
android:layout_width="40dp"
android:layout_height="30dp"
android:layout_alignParentTop="true" 
android:layout_centerInParent = "true">

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/app" />

 </RelativeLayout>
My footer.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="40dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true" >

<ImageView
    android:id="@+id/foot"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/app_rotate" />
代码的输出为:


如您所见,页眉部分位于片段的背景之下,而页脚部分则不在背景之下。我想看到我的页眉,就像页脚一样。正如您所看到的,我已经为页眉和页脚提供了所有xml属性,但是为什么输出不一样呢?我希望能得到你的帮助。提前谢谢

Z-元素顺序是顶部模型上的最后一个

移动此行:

<include layout="@layout/header" />
在主体之后:

</RelativeLayout>

<include layout="@layout/header" />

<!-- Footer aligned to bottom -->
<include layout="@layout/footer" />

哇!太神了我不这么认为。谢谢兄弟@bShah-酷。现在给我点爱,给我绿色支票我很急着去做,但上面说要等几分钟才能接受: