First, when creating the project in Studio, select DrawerActivity when selecting activity. The editor will automatically create a set of demos for you.

First, parse the corresponding activity:

First: the activity inherited from AppCompatActivity NavgitionView. OnNevigationItemSelectedLisenter (sideslip

Check for items in the menu section.

\

Second: This is the main layout for the activity. NavigationView should look like this:

\

NavigationView contains two sections: the green section at the top and the following menu items are separate menu items:

\

Let’s take a closer look at the two NavigationView properties: headLayout and Menu. It’s obvious: headLayout corresponds to the green section, menu corresponds to the following menu. Then we look at: in the section except NavegationView:

\

Include: a layout. We will see who the layout points to: \

\

Click on it and we can see the screenshot below: \

\

You can see that this is something outside of the NavigationView. The layout here is really just the ToolBar and below

Unexpected parts of the mail icon. This is where you can customize other controls.

Summary: DrawerLayout is equivalent to a side slide menu, is an official imitation of a modular package after a set of controls.

A main layout: DrawerLayout, which contains two parts: NavigationView, include a layout. NavigationView

It is divided into two parts: upper headLayout, lower menu.

\

Include: the layout of the official control android. Support. The design. The widget. The CoordinatorLayoutCopy the code

Sublayout: First a ToolBar, then include a layout (custom style). At the bottom is a mail icon.

Main layout outermost layer: DrawerLayout. And then we can change the NavigationView to the listView and it’ll still work.

Then include a layout with a Toolsbar and that’s all.