Android Toolbar with drawerlayout notes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.