Navigation Drawer In Android Studio With Fragments And Material Design Example

Today’s tutorial is Navigation Drawer Android Studio With Fragments And Material Design Example.

Navigation Drawer Android Studio example guides you to create a sliding navigation menu with recyclerview.

Navigation Drawer Android tutorial uses fragments for navigation purpose.

Visit this for more information about navigation drawer.

First, check the output and then follow all the steps.

How to get maximum benefit from Navigation Drawer Android example

Download Source Code For Navigation Drawer Android tutorial

Try Our App

Download DemoNuts app to learn anytime, anywhere: Click to get demonuts app

Or search “demonuts” in play store from android mobile device.

Creating Fragments Android Tutorial step by step

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Step 1: Create a new project in Android Studio.

Step 2: Update build.gradle(Module:app) file

Add below in build.gradle(Module:app) file

Final code for build.gradle(Module:app)

Step 3: Preparing two fragments

Create two fragments and give them name as “FriendListFragment” and “NotificationFragment.

Add below code in fragment_friend_list.xml

Add below code in

Copy following source code in fragment_notification.xml

Copy following code in

Step 4: Adding images

Download images and copy them into “drawable” directory.

Download icons

Step 5: Updating strings.xml and styles.xml

Update string.xml as per below code

Update styles.xml as following

Step 6: Adding toolbar.xml

Create new layout resource file and give it name as “toolbar.xml

Copy below source code in it.

Step 7: Creating lv_item.xml file

Make a new layout resource file named “lv_item.xml

This file is a recyclerview item file. Add below code in it

Step 8: Creating Model

Create a new Java class named “DrawerModel” and add following code

Step 9: Making Recyclerview Adapter

Create a new Java class named “DrawerAdapter” and paste below code

Step 10: Creating DrawerFragment

Make a new fragment named DrawerFragment.

Add below source code in fragment_drawer.xml

Add following source code into

Step 11: Description of

In onCreateView() method, recyclerview is initialized and its onClick() method is implemented.

For recyclerview’s onClick() method implementation, a class named RecycletTouchListener and an interface named ClickListener is defined.

openFragment() method will open fragment. Here, a removeAllFragment() method is used to remove all fragments from back stack and open a fresh new fragment.

setUpDrawer() method will be used in MainActivity.

Step 12: Updating MainActivity

Copy below code into activity_main.xml

Update as per following

Kotlin Version

Kotlin version of this tutorial : Navigation Drawer Android Kotlin

Searching Perfect Android Example In Google

Click to get Important Google searching tips

The End for Navigation Drawer In Android Studio example.

Comment if you have queries or want to give a review. Thank you 🙂

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *