Browse Tag

Navigation Component

Navigation Component: How to move the Drawer under the ToolBar?

Navigation Drawer Activity Template

Recently I was struggling with Navigation Component and succeded in solving some of its issues. I am happy to share with you the solutions I’ve found.

GitHub Repo: https://github.com/Pulimet/NavigationComponentSample

Create a project and select the template “Navigation Drawer Activity”. You will get the ToolBar, Drawer and navigation stuff for free as shown in the screenshot.

Now, let’s assume that we got a request to move the drawer under the ToolBar. We need to modify activity_main.xml for that.

Create vertical LinearLayout and make it wrapping DrawerLayout

Open app_bar_main.xml copy AppBarLayout and paste it as a first item in the previously created LinearLayout.

Also from the app_bar_main.xml get the include (content_main) and put it as a first child of DrawerLayout instead of existing include of app_bar_main.xml.

Delete app_bar_main.xml file

In v21\styles.xml – remove the line that makes status bar transparent.

Keep Reading