3
所以我的XML是這樣的:使用程序兼容性工具欄用的FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<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.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_height="56dp"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<FrameLayout
android:id="@+id/main_frag"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- ListView here -->
</android.support.v4.widget.DrawerLayout>
發生了什麼,即使我把我的高度明確爲56dp,該toolbar
行事像match_parent
和遺囑屏幕的整個高度?有沒有更好的方法來做到這一點?
或者我應該把工具欄放在我的FragementTransaction
s填充FrameLayout
的佈局中?這似乎並不高效,因爲我有其中幾個。
我不明白你爲什麼會走這條路,而不是在一個LinearLayout中包裹的一切,然後在抽屜佈局上方的工具欄 – tyczj 2014-10-29 16:27:45
@tyczj我一直認爲'DrawerLayout'必須支持xml文件。 – KickingLettuce 2014-10-29 16:30:21
@tyczj - 你看過我鏈接的帖子吧?您將無法正確執行抽屜(在工具欄上方,並按照[材料設計準則](http://android-developers.blogspot.com/2014/10/material-design- on-android-checklist.html) - 如果你不把'Toolbar'放在'DrawerLayout'中,請參閱Navigation Drawer部分。 – ianhanniballake 2014-10-29 16:31:19