Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java for Android
  • Android Studio
  • Android Kotlin
  • Kotlin
  • Flutter
  • Dart
  • Android Project
  • Android Interview
Open In App
Next Article:
How to Add Icons in Navigation Drawer in Android?
Next article icon

How to Add Icons in Navigation Drawer in Android?

Last Updated : 28 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Android navigation drawer is a user interface that shows the app's main navigation menu. It appears when the user touches the drawer icon in the app bar or when the user swipes their fingers or does some kind of action on the screen. It is not visible by default and it needs to open either by sliding from the left or clicking its icon in the ActionBar. It shows all the internal of the app and its functionalities.

Android Icons

Android icons represent our app on a device's Home and All Apps screens. They are the symbolic representation of all functions present in the app.

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:

In your res folder make a menu folder. In it add xml file name nav_menu. Add this below code.

XML
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tool="http//schemas.android. com/tools"     tool:showIn ="navigation_view">     <group         android:checkableBehavior="single">         <item             android:id="@+id/nav_home"             android:title="Home"             android:icon="@drawable/home">         </item>          <item             android:title="Attendance Track"             android:id="@+id/attend_track"             android:icon="@drawable/baseline_how_to_reg_24">         </item>          <item             android:title="QR Scan"             android:id="@+id/scan_qr"             android:icon="@drawable/baseline_qr_code_scanner_24">         </item>     </group>      <item android:title="General">         <menu>                 <item android:title="Profile"                     android:id="@+id/profile"                     android:icon="@drawable/user"/>              <item android:title="Settings"                 android:id="@+id/settings"                 android:icon="@drawable/baseline_settings_24"/>         </menu>     </item>      <item android:title="Communicate">         <menu>                 <item                     android:title="How To Use"                     android:icon="@drawable/baseline_emoji_people_24"                     android:id="@+id/use"/>                 <item                     android:title="Suggestions"                     android:icon="@drawable/question"                     android:id="@+id/sugg"/>                 <item android:title="Share App"                     android:icon="@drawable/baseline_share_24"                     android:id="@+id/share"/>         </menu>     </item> </menu> 
 

Step 3:

In your layout folder add nav_header.xml. Add the below code

XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout      xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="176dp"     android:orientation="vertical"     android:gravity="top"     android:padding="10dp"     android:background="@drawable/grad">      <TextView         android:layout_marginTop="10dp"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="Navigation Bar"         android:layout_marginLeft="9dp"         android:fontFamily="@font/regular"         android:textSize="20sp"         android:textColor="@color/white"         android:textStyle="bold"/>    </LinearLayout> 
 

Step 4:

In your drawable folder make a grad.xml .Add this code to it.

XML
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item>         <shape             android:shape="rectangle">             <corners                 android:bottomLeftRadius="15dp"                 android:bottomRightRadius="15dp">             </corners>             <gradient                 android:startColor="#615EE8"                 android:endColor="#7F6CEF"/>         </shape>     </item> </selector> 
 

Step 5:

Go to your main activity and add the code given below.

XML
<?xml version="1.0" encoding="utf-8"?> <androidx.drawerlayout.widget.DrawerLayout      xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:id="@+id/drawer_layout"     android:fitsSystemWindows="true"     tools:openDrawer="start"     tools:context=".MainActivity">      <LinearLayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical">          <Toolbar             android:layout_width="match_parent"             android:layout_height="56dp"             android:id="@+id/toolbar"             android:elevation="4dp"             android:background="@color/grad_1"             android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"             android:popupTheme="@style/ThemeOverlay.AppCompat.Light"             tools:targetApi="lollipop" />                  <FrameLayout             android:layout_width="match_parent"             android:layout_height="match_parent"             android:id="@+id/frag_con"/>                  </LinearLayout>  <com.google.android.material.navigation.NavigationView     android:layout_width="wrap_content"     android:layout_height="match_parent"     android:id="@+id/nav_view"     android:layout_gravity="start"     app:headerLayout="@layout/nav_header"     app:menu = "@menu/nav_menu"     app:itemIconTint="@color/grad_2">  </com.google.android.material.navigation.NavigationView>  </androidx.drawerlayout.widget.DrawerLayout> 

Output:

 

Next Article
How to Add Icons in Navigation Drawer in Android?

S

shrutisaini1415
Improve
Article Tags :
  • Android
  • Android Navigation

Similar Reads

    How to Check Navigation Drawer Menu Items in Android?
    Navigation Drawer or Slider Drawer is a UI component that is used in Mobile Applications and Websites to provide easy access to different features or parts of an app or website. Functioning of Navigation Drawer It is generally accessed by tapping on the hamburger menu icon (3 horizontal lines), pres
    4 min read
    How to Grouping Navigation Drawer Menu Items in Android?
    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 DrawerIt is usually accessed by tapping on the hamburger menu icon (3 horizontal lines), prese
    4 min read
    Navigation Drawer in Android
    The navigation drawer is the most common feature offered by Android and the navigation drawer is a UI panel that shows your app's main navigation menu. It is also one of the important UI elements, which provides actions preferable to the users, for example changing the user profile, changing the set
    5 min read
    How to Hide NavigationBar in Android?
    NavigationBar in Android is a row comprising the back button, home button, and Recent button located at the bottom of the application. Most Android 5.0 Lollipop and above devices have no physical navigation buttons and hence come as buttons present on the screen throughout the screen life. However,
    2 min read
    Navigation Drawer in Java Android
    A Navigation Drawer is the UI panel that can show the app's main navigation menu. When the user swipes from the left edge of the screen or touches the app icon in the action bar and the drawer appears. It can provide a simple way to navigate between the different sections of the application. This ar
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences