【发布时间】:2014-12-15 08:34:30
【问题描述】:
如何使抽屉布局位于操作栏/工具栏下方?我正在使用带有新工具栏视图的 v7:21 应用兼容库。
我看到的例子看起来像
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- drawer view -->
<LinearLayout
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start">
<!-- drawer content -->
</LinearLayout>
<!-- normal content view -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- The toolbar -->
<android.support.v7.widget.Toolbar
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />
<!-- The rest of content view -->
</LinearLayout>
但是工具栏将被抽屉隐藏,这使得动画汉堡图标(如 v7.ActionBarDrawerToggle)无用,因为它在抽屉下方不可见,但我确实想使用新的 ToolBar 视图来支持 Material主题更好。
那么如何实现呢?是否可以将 DrawerLayout 作为非顶级视图?
【问题讨论】:
-
@AnupamChugh - 您在上面提供的链接 (journaldev.com/12648/navigationview-android) 确实是我想要的。谢谢!!
-
很高兴它帮助了你!
标签: android navigation-drawer android-support-library toolbar drawerlayout