Java 如何在工具栏后面设置导航抽屉
我正在尝试设置Java 如何在工具栏后面设置导航抽屉,java,android,xml,navigation-drawer,Java,Android,Xml,Navigation Drawer,我正在尝试设置工具栏后面的导航抽屉,我已尝试设置 android:layout\u marginTop=“@dimen/abc\u action\u bar\u default\u height\u material”到NanvigationView但没有任何更改,我也遵循此操作,但不起作用 activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="htt
工具栏后面的导航抽屉
,我已尝试设置
android:layout\u marginTop=“@dimen/abc\u action\u bar\u default\u height\u material”
到NanvigationView
但没有任何更改,我也遵循此操作,但不起作用
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>
<?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>
App_bar_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>
<?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>
为activity\u main.xml尝试下一个代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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:theme="@style/NavigationView"
android:background="#2b2b2b"
app:itemTextColor="#FFF"
app:menu="@menu/activity_main_drawer"
android:layout_marginTop="@dimen/appbar_height"/>
appbar\u height
-您在dimen.xml中的值。它可以等于activity_main.xml的下一个代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<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:theme="@style/NavigationView"
android:background="#2b2b2b"
app:itemTextColor="#FFF"
app:menu="@menu/activity_main_drawer"
android:layout_marginTop="@dimen/appbar_height"/>
appbar\u height
-您在dimen.xml中的值。它可以等于?actionBarSize
@MikeM。我同意答案,但没有work@MikeM. 请检查我的更新代码,我试图设置:RelativeLayout---Toolbar---DrawerLayout---ContentView---DrawerList
@MikeM。不幸的是她没有工作,我试着像你说的那样把
放在
之前的
中,但在我运行它时没有工作,还是一样changed@MikeM. 我知道我打扰了你,但我添加了app\u bar\u main
请帮助我们融合。@MikeM。我同意答案,但没有work@MikeM. 请检查我的更新代码,我试图设置:RelativeLayout---Toolbar---DrawerLayout---ContentView---DrawerList
@MikeM。不幸的是她没有工作,我试着像你说的那样把
放在
之前的
中,但在我运行它时没有工作,还是一样changed@MikeM. 我知道我打扰了你,但我添加了app\u bar\u main
请帮助我们。