Navigation Drawer In Android Kotlin With Fragments And Material Design Example

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

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

Navigation Drawer Android Kotlin tutorial uses fragments for navigation purpose.

Visit this for more information about navigation drawer.

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

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 FriendListFragment.kt

Copy following source code in fragment_notification.xml

Copy following code in NotificationFragment.kt

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 Kotlin class named “DrawerModel” and add following code

Step 9: Making Recyclerview Adapter

Create a new Kotlin 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 DrawerFragment.kt

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 MainActivity.kt as per following

Java Version

Java version of this tutorial : Navigation Drawer Android

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 🙂

Download Source Code For Navigation Drawer Android Kotlin tutorial


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...

2 Responses

  1. Craig says:

    thanks for the tutorial, do you have the source code to download?

Leave a Reply

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