简体   繁体   中英

Aligning LinearLayout to the bottom of a DrawerLayout

I've implemented a DrawerLayout in my application's primary XML layout - and I've created a footer (basically a horizontal [navigation-ish] bar) which fill the bottom of the screen. The problem is - it is continually appearing at the top of the screen... I've attempted using android:layout_gravity="bottom" , android:layout_weight="1.0" and android:baselineAligned="false" as documented here: http://sandipchitale.blogspot.com/2010/05/linearlayout-gravity-and-layoutgravity.html However I still cannot seem to get the footer from appearing at the top of the layout.

Any suggestions are appreciated:

XML Snippet:

<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>

Full XML Source:

http://pastebin.com/67cHtwJ1

Screenshot:

在此处输入图片说明

You should be applying layout_gravity:bottom to the LinearLayout, not the DrawerLayout. The layout_ prefix lets the child tell the parent how it would like to be laid out, positioned, etc. android:gravity should be applied to a parent view and is used to position all of its children.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM