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