generated by Android Studio Nagvition Drawerlayout Activity comes with the layout of the Nagvitionview will cover toolbar directly to StatusBar.
But I want to control the Nagvationview to Toobar below, the answer from the Internet is to remove toolbar from the coordinatorlayout , and then
Main layout file:
<?xml version="1.0"encoding="Utf-8"? ><linearlayout xmlns:android="http://schemas.android.com/apk/res/android"Xmlns:app="Http://schemas.android.com/apk/res-auto"Android:layout_width="match_parent"Android:layout_height="match_parent"android:orientation="Vertical"> <Android.support.v7.widget.Toolbar Android:id="@+id/toolbar"Android:layout_width="match_parent"Android:layout_height="? attr/actionbarsize"Android:background="? Attr/colorprimarydark"/> <android.support.v4.widget.DrawerLayout Android:id="@+id/drawer_layout"Android:layout_width="match_parent"Android:layout_height="match_parent"> <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"App:menu="@menu/activity_main_drawer"/> </android.support.v4.widget.DrawerLayout></LinearLayout>
This will be possible, but finding the tool will have a strange effect such as:
In fact, the coordinatorlayout property is set to Android: fitssystemwindows="true", the attribute is removed just fine.
App_bar_main layout:
1 <Android.support.design.widget.CoordinatorLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"2 Xmlns:tools= "Http://schemas.android.com/tools"3 Android:layout_width= "Match_parent"4 Android:layout_height= "Match_parent"5 android:fitssystemwindows = "true"<!--remove this sentence --6 Tools:context= "Com.mmmmar.box.MainActivity">7 8 <includeLayout= "@layout/content_main" /><!--your own layout -9 Ten <Android.support.design.widget.FloatingActionButton One Android:id= "@+id/fab" A Android:layout_width= "Wrap_content" - Android:layout_height= "Wrap_content" - android:layout_gravity= "Bottom|end" the Android:layout_margin= "@dimen/fab_margin" - android:src= "@android:d rawable/ic_dialog_email" /> - - </Android.support.design.widget.CoordinatorLayout>
Android Toolbar with drawerlayout notes