【发布时间】:2017-04-29 14:21:11
【问题描述】:
我正在尝试将 Navigation drawer 设置在 Toolbar 后面,我已经尝试设置
android:layout_marginTop="@dimen/abc_action_bar_default_height_material" 到 NanvigationView 但没有任何改变,我也关注此 Navigation Drawer Below Toolbar 但不起作用
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/top_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="false"
android:theme="@style/NavigationView"
android:background="#2b2b2b"
app:itemTextColor="#FFF"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
App_bar_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="maa.a4kandhdwallpapers.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
-
@MikeM。我遵循已批准的答案,但不起作用
-
@MikeM。请检查我尝试设置的更新代码:
RelativeLayout ----Toolbar ----DrawerLayout ---ContentView ---DrawerList -
@MikeM。不幸的是,她没有工作,我尝试将
<include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" />放在<DrawerLayout>之前的<NavigationView>之前,就像你说的那样,但是当我运行它时仍然不起作用,没有任何改变 -
@MikeM。我知道我打扰了你,但我添加了
app_bar_main请帮助我
标签: java android xml navigation-drawer