我如何DrawerLayout显示下面的工具栏? [英] How do I make DrawerLayout to display below the Toolbar?
问题描述
如何使抽屉布局是动作条/工具栏下面?我使用的是V7:21应用程序兼容性库与新的工具栏视图
例子,我看到的样子
< android.support.v4.widget.DrawerLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / my_drawer_layout
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<! - 抽屉查看 - >
<的LinearLayout
机器人:layout_width =304dp
机器人:layout_height =match_parent
机器人:layout_gravity =左|启动>
<! - 抽屉的内容 - >
< / LinearLayout中>
<! - 普通内容视图 - >
<的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直>
<! - 工具栏 - >
< android.support.v7.widget.Toolbar
机器人:ID =@ + ID / my_awesome_toolbar
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =match_parent
机器人:=了minHeight?ATTR / actionBarSize
机器人:后台= />中ATTR / colorPrimary?
<! - 内容视图的其余部分 - >
< / LinearLayout中>
但随后的工具栏将被抽屉,这使得动画汉堡包图标(如v7.ActionBarDrawerToggle)隐藏无用的,因为它不会是抽屉下方可见的,但我确实希望使用新的工具栏视图,支持材料主题好。
那么如何实现这一目标?是否有可能有DrawerLayout作为非顶级的看法?
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:方向=垂直
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<! - 工具栏 - >
< android.support.v7.widget.Toolbar
机器人:ID =@ + ID / my_awesome_toolbar
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =match_parent
机器人:=了minHeight?ATTR / actionBarSize
机器人:后台= />中ATTR / colorPrimary?
< android.support.v4.widget.DrawerLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / my_drawer_layout
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<! - 抽屉查看 - >
<的LinearLayout
机器人:layout_width =304dp
机器人:layout_height =match_parent
机器人:layout_gravity =左|启动>
<! - 抽屉的内容 - >
< / LinearLayout中>
<! - 普通内容视图 - >
<的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直>
<! - 内容视图的其余部分 - >
< / LinearLayout中>
< /android.support.v4.widget.DrawerLayout>
< / LinearLayout中>
How to make the drawer layout be below the actionbar/toolbar? I'm using v7:21 app compat library with the new ToolBar view.
Examples that I see looks like
<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>
But then the toolbar will be hidden by the drawer, which makes an animated hamburger icon (like v7.ActionBarDrawerToggle) useless since it will not be visible below the drawer, but I do want to use the new ToolBar view to support Material theme better.
So how to accomplish that? Is it possible to have DrawerLayout as a non top-level view?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 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" />
<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 rest of content view -->
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
这篇关于我如何DrawerLayout显示下面的工具栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!