将 LinearLayout 对齐到 DrawerLayout 的底部

Aligning LinearLayout to the bottom of a DrawerLayout

我在我的应用程序的主要 XML 布局中实现了一个 DrawerLayout - 我已经创建了一个填充屏幕底部的页脚(基本上是一个水平的 [navigation-ish] 栏)。问题是 - 它不断出现在屏幕顶部...我尝试使用 android:layout_gravity="bottom"android:layout_weight="1.0"android:baselineAligned="false",如下所述:http://sandipchitale.blogspot.com/2010/05/linearlayout-gravity-and-layoutgravity.html 但是我似乎仍然无法让页脚出现在布局的顶部。

如有任何建议,我们将不胜感激:

XML 片段:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:background="@color/black"
    android:baselineAligned="false" >



    ...



        <LinearLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1.0"
        android:orientation="horizontal" >
    </LinearLayout>

</android.support.v4.widget.DrawerLayout>

完整 XML 来源:

http://pastebin.com/67cHtwJ1

截图:

您应该将 layout_gravity:bottom 应用于 LinearLayout,而不是 DrawerLayout。 layout_ 前缀让子级告诉父级它希望如何布局、定位等。android:gravity 应用于父视图并用于定位其所有子级。