Android Navigation Drawer Tutorial with Example

By | June 11, 2019
Navigation Drawer in Android Tutorial Example

What is Navigation Drawer in Android ?

Navigation drawer is a sliding menu and it’s an important UI component. Navigation Menu appears on the android screen with a hamburger menu icon in the ActionBar.

Navigation drawer is used to Drawer Layout in xml layout file.  It is not visible by default you needs to opened sliding from left or clicking its icon in the ActionBar.

 Navigation Drawer is an overlay panel. it is a replacement of an activity screen and it was specifically dedicated to show all the options and links in the application.

Navigation drawer is declared menus and this menu when you click menu to open fragments or activity to android screen and it is automatically close navigation drawer.

It is mostly used to header view below the menu section item. you can create custom navigation drawer in android.

Example of Navigation Drawer in Android

you can declared dependency in app level build.gradle File.

Create activity_main.xml File Follow this code.

Create toolbar_layout.xml layout XML File Follow this code.

Create header_layout.xml File Follow this code.

Create fragment_home.xml File Follow this Code.

Create Fragment fragment_message.xml File Follow this code.

Create fragment_setting.xml File Follow this code.

Create Menu file From res/menu directory drawer_menu.xml File Follow this Code.

Add String Resource in res/values/strings.xml File.

Create File Follow this code.

Create File Follow this code.

Create File Follow this Code.

Create File Follow this Code.

In this Tutorial to Create Simple Navigation Drawer. In this example used to drawer layout in MainActivity xml file and create custom toolbar and this toolbar used to drawer layout file to include tag.

Create custom header layout file used to navigation define header and create three fragments and create drawer menu xml file. in this file used to drawer display menu item when you can click on menu item to open fragment in right side screen and close automatically drawer.

Now in this drawer is custom header to define your name and other view you can design in customization.