VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-grouping-navigation-drawer-menu-items-in-android/

⇱ How to Grouping Navigation Drawer Menu Items in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Grouping Navigation Drawer Menu Items in Android?

Last Updated : 23 Jul, 2025

Navigation Drawer or Slider Drawer is a UI pattern, used in Mobile Applications and Websites. It is used to provide easy access to different features or parts of an app or website.

Functioning of Navigation Drawer

It is usually accessed by tapping on the hamburger menu icon (3 horizontal lines), present in the top-left or top-right corner of the screen, or swiping from the left edge of the screen.

Components of Navigation Drawer 

  • Drawer Header Layout: Contains additional information, such as User’s profile picture or App Name/ Website Name, etc.
  • Menu: Contains a list of options or menu items that the user can navigate to. Users can select and menu item by clicking on it, then it will load a new screen based on the backend of the app or website.

Need of Grouping Menu Items

  • Improves User Experience
  • Ensures the correct functioning of the app
  • Maintaining a cohesive user interface
  • Makes a user-friendly experience
  • Reduces vagueness

Step by Step Implementation

Step 1: Create a New Project in Android Studio

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Step 2: Adding Material Design dependency in build.gradle.kts (Module g:app)

dependencies {
...
implementation ("com.google.android.material:material:1.12.0")
}


Step 3: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. Comments are added inside the code to understand the code in more detail.

activity_main.xml:


Step 4: Working with the nav_header.xml file

Navigate to the app > res > layout > nav_header.xml and add the below code to that file. Below is the code for the nav_header.xml file.

nav_header.xml:


Step 5: Working with the nav_menu.xml file

Navigate to the app > res > menu > nav_menu.xml and add the below code to that file. Make sure to add a relatable menu icon in the drawable file. Below is the code for the nav_menu.xml file.

nav_menu.xml:


Step 6: Working with the MainActivity file

Go to the MainActivity file and refer to the following code. Below is the code for the MainActivity file. Comments are added inside the code to understand the code in more detail.

MainActivity File:


Step 7: Working with strings.xml

Navigate app > res > values > strings.xml and add the following values

<resources>
...
<string name="open_drawer">Open navigation drawer</string>
<string name="close_drawer">Close navigation drawer</string>
</resources>

Output:


Comment

Explore