簡體   English   中英

將LinearLayout與DrawerLayout的底部對齊

[英]Aligning LinearLayout to the bottom of a DrawerLayout

我已經在應用程序的主要XML布局中實現了DrawerLayout,並且創建了一個頁腳(基本上是水平[導航]欄),該頁腳填充了屏幕的底部。 問題是-它不斷出現在屏幕頂部...我嘗試使用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應該應用於父視圖,並用於放置其所有子對象。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM