1
我有一個名爲footer.xml的佈局,稍後將包含在多個佈局中。 Footer.xml如下:如何將包含的佈局推到屏幕底部?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bottomMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_gradation"
android:weightSum="1" >
*** STUFF GOES HERE ***
</LinearLayout>
然後Footer.xml將被包括在其他佈局如下..
<?xml version="1.0" encoding="utf-8"?>
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/backrepeat">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<LinearLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="0dp"
android:weightSum="1">
<ListView
android:id="@+id/chatListView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:divider="#00000000"
android:scrollbars="none"
android:dividerHeight="1dp"
android:layout_weight=".80"/>
<LinearLayout
android:id="@+id/chatBar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".13"
android:orientation="horizontal"
android:background="#242424"
android:weightSum="1">
</LinearLayout>
</LinearLayout>
<include layout="@layout/footer"/>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
因爲我想footer.xml是在屏幕底部,我用android:layout_gravity="bottom"
這使它正確,如果從footer.xml的角度來看
然而,當我試圖把它從其他的佈局,它拋出的錯誤,說:
java.lang.UnsupportedOperationException (Error Log does not show helpful information at all).
編輯1 這是最好的錯誤消息,我能得到..(我不能複製粘貼記錄文本)
EDIT 2 如果我有我的佈局這樣:
<LinearLayout
android:layout_weight="1"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include layout="@layout/footer"
android:id="@+id/footer"/>
</LinearLayout>
它呈現了我希望它在Eclipse編輯器中的方式。
java.lang.IllegalStateException: Child android.widget.LinearLayout{a72d4938 V.E..... ......ID 0,0-0,0 #7f0a005c app:id/bottomMenu} at index 1 does not have a valid layout_gravity - must be Gravity.LEFT, Gravity.RIGHT or Gravity.NO_GRAVITY
,如果我editted我footer.xml這樣::
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bottomMenu"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" <---- not android:layout_gravity="bottom"
android:background="@drawable/bg_gradation"
android:weightSum="1" >
我的頁腳將填滿整個屏幕的但是,當我嘗試在Android上我碰到下面的錯誤運行從上到下。
任何人都可以幫助我嗎?謝謝..
喜它仍然拋出了同樣的錯誤 – Jeremy
請加上完整的崩潰日誌 –
把代碼它不是足夠和你從其他地方得到問題 – DropAndTrap