Android 无法为其他xml中包含的布局对齐底部功能

Android 无法为其他xml中包含的布局对齐底部功能,android,android-layout,alignment,Android,Android Layout,Alignment,我有一个页脚xml文件。我将该文件包括在所有其他文件中,如 <RelativeLayout android:id="@+id/footer" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true"> <include layout="@layout/foot

我有一个页脚xml文件。我将该文件包括在所有其他文件中,如

 <RelativeLayout
     android:id="@+id/footer"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true">

     <include layout="@layout/footer" />
 </RelativeLayout>

但我收到了类似“LinearLayout中的布局参数无效:layout\u alignParentBottom”的警告
有谁能告诉我如何在不使用大小的情况下对齐底部包含的xml吗?

您不能在LinearLayout中使用property
alignParentBottom
。那是给你的

对于线性布局,可以使用
layout\u gravity

<LinearLayout> <!-- container LinearLayout -->
    <LinearLayout
         android:id="@+id/footer"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_gravity="bottom">

         <include layout="@layout/footer" />
     </LinearLayout>
</LinearLayout>


希望这能有所帮助。

这段代码将把你的东西放到底部(页脚)

这将是您的页脚XML

footer.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/footer_test"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:gravity="bottom"
            android:layout_alignParentBottom="true"> 
      </RelativeLayout>

现在,将页脚xml包含在您想要的布局中

比如,

abc.xml

<LinearLayout
        android:id="@+id/abc_test"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <include layout="@layout/footer"
         android:id="@+id/footer_test"/>

</LinearLayout>


希望这对您有所帮助:)

将您最顶层的布局更改为RelativeLayout,这样您就可以在使用布局时设置android:layout\u alignParentBottom=“true”选项卡栏图像不会显示。我有一个带有图像和文本的选项卡栏,这意味着你的布局结构有问题。显示完整的xml。