Create a Navigation Drawer Material Design in Android Studio tutorial

by | Feb 15, 2020 | Android, Android for Beginners, Android Material Design Tutorials, Android UI/UX Tutorials, Basics, UI UX | 0 comments

In this tutorial series, we will be creating an Android Navigation Drawer Material design in android studio.

We will also learn

  1. Create a Navigation Drawer with the Hamburger menu icon.
  2. Design menu header in the navigation bar.
  3. Hide navigation menu item android action bar.

What is Navigation Drawer Menu?

Navigation Drawer is the main menu in android applications that slides from the side of the application by clicking on the hamburger icon.

Navigation is how people move from one activity to another in our application.

Therefore navigation plays an important role in increasing the usability of an application. Thus for navigation, menus are used.

However, to navigate in our application we have to make menus and the right place for placing menus in android is Navigation Drawer.

As we all know we are making a travel application in android studio.

So, this tutorial is about making Navigation Drawer and we have made 3 videos of it.

Worry?? Don’t be upset we will make the Navigation drawer menu in less than 30 minutes. But for that, you have to stay with us. And if you want to see videos, simply click this playlist.

As you see, we have mentioned material design in the title of this tutorial. First question first, what is it?

What is Material Design?

Material design is a language that designs components using new and innovative technology.


Why to use Material Design in android?

Designing is an important factor to make an application attractive and good looking.

As we all know everyone wants to design his/her application that leaves an impact on the user.

But as we all know, designing an application takes a lot more time than functionality.

So developers do less designing.

Material design helps us in designing applications very quickly.

It provides Visual design, motion design and interaction design across different platforms.

You can design Text ViewsButtons, Check Boxes and much more.

let’s get started without wasting time.

Dashboard is the main activity of an application and to design that, takes much time than designing other activities.

We had made a Dashboard in the previous tutorial. As you have seen it in title image or video thumbnail.

And if you like it and want to know how to make it just click this link Material Dashboard Design in Android Studio

Now get back to the Navigation Drawer.


To create a Navigation Drawer using material design in android studio you have to follow some steps.

Steps to create a Navigation Drawer Material Design

  1. Create a new android studio project if you have not already created it.
  2. And Design the main activity.
  3. Add Icons you want to use in project.
  4. Create Menu Resource File.
  5. Make menu header layout
  6. Design the MainActivity

Step #1: Create a new project

For the creation of a new android studio project, click on Start a new Android Studio project as shown in the picture.

Or if you have already created a project, you have to open it.

After creating a project you have to select an activity. So we suggest you to select an empty activity.

Name your activity in the Name field. And select the language Java in the Language field.

Then click on the finish button.

Step #2: Add icons to the android project

There are two ways to use icons in your android studio project. 

1. Upload icons to your project.

To upload an icon in your project copy your downloaded icon and right-click on drawable and paste your icon. “app>res>drawable”

2. Use default icons of the android studio.

Go to app>res>drawable

right-click on drawable select New>VectorAsset.

After that, a form will open, from where you can select the icon and change the color or size of that icon.

Therefore choose icon, next change the name and select color you want to use then select “Next”.

Then select Finish

Step #3: Create menu Resource file for Navigation drawer

In the first place, make a folder/directory in which we can put menu resource file.

So for that, make a new folder by right-clicking on res->new->Android resource directory.

In the meantime choose resource type to “menu”. if you want to change directory name change it but in this case, we will leave as it is.

Then select “OK”. As shown in the picture.

Subsequently, a new resource folder/directory has been added in your res directory named as “menu”.

Right-click on menu->new and select “Menu resource file”.

Name the file name as main_menu.

Make sure the “source set” is main.

then click on the ok button.

Design Menu Resource File

In the first place, open menu resource file “main_menu.xml”

In the meantime, the design file will open. Now, click on the text tab at the bottom with the design tab.

To make the menu in groups needs group tag is used.

Therefore if we want to make a menu of more than one category then we will have to make different groups.

In addition to it, the question arises here is how to use a group tag.

So the <group> tag is used the same as other tags. Such as in the code below.

<group android:checkableBehavior="single">

As you have seen that in the group tag we write checkable behavior = single.

Thus this means that one menu item of the group is selected at one time.

In between the group tag, we have to place item tag with id, icon, and title of the item.

Code given below

            android:title="Home" />

            android:title="Cycling" />

            android:title="Bus" />

            android:title="Plane" />

    <item android:title="Profile">


            <group android:checkableBehavior="single">

                    android:title="Login" />

                    android:title="Profile" />

                    android:title="Logout" />

    <item android:title="Communicate">


                android:title="Share" />

                android:title="Rate Us" />

Step #4: Create a menu header file of Navigation drawer

After making a menu of navigation drawer now create the header of that menu.

Hence make a new layout resource file for the header in the navigation drawer menu.

So, Right-click on res->layout->new and select “Layout resource file”.

Likewise, give the name the file as “header”.

Accordingly, make sure that the “source set” is main.

finally, click on the ok button.

Design menu header file

In the meantime Open layout resource file named as header.xml.

The layout used in the header file of the navigation drawer is a Linear Layout.

In this case, we are making the header of a menu so make the layout_height of 200dp and orientation is vertical.

Give the background image and assign the gravity to “bottom”..

After that add the Image view tag and Text view tag as shown in the code

        android:src="@drawable/icons8_cycling_500" />

        app:fontFamily="@font/baloo" />

        app:fontFamily="@font/aclonica" />

Step #5: Design the main activity of our application

Design your main activity according to your will but if you want to get my design the simply go to the Dashboard Design tutorial.

However, if you use our designed dashboard then you have to make some changes in it.

As a result, change the parent layout of the main activity of the dashboard with the following code.

<androidx.drawerlayout.widget.DrawerLayout xmlns:android=""

Add a Navigation View in the layout

Now add a navigation view inside the layout of main-activity.

To use that we have to add a dependency.

There are two ways to add a dependency.

Accordingly paste the dependency in build.gradle file.

implementation ''

2nd way is to GOTO Design section of activity_main.xml


  • In the first place goto the Container in Palette
  • Afterward, Search for Navigation View
  • Finally, click on the downloadable icon which is at the right of Navigation View Widget.

After adding the navigation view, go-to text and add the following code.

    app:menu="@menu/main_menu" />

“app:headerLayout” and “app:menu” are the layouts we have created before. Thus, name them.

Make sure the layout_gravity is start.

Step #6: Add functionality to file

Later on, add hooks of the components to be used in further code. As we see in the code below.

1- Add Hooks of the components used in the design.

DrawerLayout drawerLayout;
        NavigationView navigationView;
        Toolbar toolbar;
        Menu menu;
        TextView textView;

protected void onCreate(Bundle savedInstanceState){

2- Add a Navigation drawer Code

After that, add the code of navigation drawer to be visible.

        ActionBarDrawerToggle toggle=new

3-Handle onBackPressed() method

We will implement this method because we want to close the drawer when a back button is pressed on mobile and the drawer is Open.

So, when we push the back button then our navigation drawer will be closed.

public void onBackPressed(){

Implement onNavigationItemSelected() method

This method helps in the functionality or our navigation drawer.

In this function, we tell that which activity will open when the menu in the navigation drawer is selected.

For that, we have to use “intent” and call the activity we want to open on menu selected.

public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
    switch (menuItem.getItemId()) {
        case break; case
            Intent intent = new Intent(MainActivity.this, Bus.class);
        case menu.findItem(;
        case menu.findItem(;
        case Toast.makeText(this, "Share", Toast.LENGTH_SHORT).show(); break;
    drawerLayout.closeDrawer(GravityCompat.START); return true;

Show or hide Items in navigation drawer

menu = navigationView.getMenu();

Get Complete Source code for Bull’s Rent App


🚀 Supercharge your Flutter skills! Subscribe to my YouTube channel now for mind-blowing coding insights, expert tips, and exclusive content. Don’t miss out!


Android firebase app - android app 2022 - firebase android app - bulls rent app - coding with t app - android app
android complete login signup product by taimoor sikander free for any type of android app
Flutter E Commerce App Modern and latest
Flutter Login App UI Source Code - Flutter Complete App - Flutter App Design - Flutter App 2023 - Complete Flutter App 2023
Learn flutter from scratch in 4 hours - Flutter Crash Course - Coding with T

Latest Tutorial

How to create a Custom Appbar in flutter. Custom Appbar Design. Flutter App Design
How to create a Custom Shape in Flutter. Flutter E Commerce app Design. Ecommerce app design Flutter. Flutter clippath tutorial
Bottom Navigation bar in Flutter. Flutter Material 3 bottom navigation bar. How to design background color of Flutter bottom navigation bar. Flutter ecommerce app design
Access Admin Panel, Premium Tutorials, Live Chat, 50% off Codes, and More on Patreon!
This is default text for notification bar