Navigation Drawer Navigation Drawer is a side menu panel that consists of different navigating fragments. The menu is provided at the left of the screen which opens and closes as per your user requirements, There are different fragments present in the menu, so when you click on any one fragment it will lead you to a different screen.
The best example would be Gmail App, when you click on the menu a side panel opens up that consists of All Inboxes, Primary, Promotions, and Socials.
Download the Logo and Background Logo:
Header Background:
Step-by-Step Implementation 
Step 1: Open Android Studio, Create New Project, Choose Empty Activity and Name the Project “Navigation Drawer”. 
Step 2: colors.xml 
< ?xml version= "1.0"  encoding= "utf-8" ? > 
     < color name= "purple_200" > #FFBB86FC</color> 
     < color name= "purple_500" > #FF6200EE</color> 
     < color name= "purple_700" > #FF3700B3</color> 
     < color name= "teal_200" > #FF03DAC5</color> 
     < color name= "teal_700" > #FF018786</color> 
     < color name= "black" > #FF000000</color> 
     < color name= "white" > #FFFFFFFF</color> 
     < color name= "lavender" > #8692f7</color> 
Step 3: strings.xml 
     < string name= "app_name" > Navigation Drawer < /string > 
     < string name= "open_nav" > Open Navigation Drawer < /string > 
     < string name= "close_nav" > Close Navigation Drawer < /string > 
Step 4: themes.xml 
< resources xmlns:tools= "http://schemas.android.com/tools" > 
     < !-- Base application theme. -- > 
     < style name= "Theme.NavigationDrawer"  parent= "Theme.MaterialComponents.DayNight.DarkActionBar" > 
         < !-- Primary brand color. -- > 
         < item name= "colorPrimary" > @color/lavender < /item > 
         < item name= "colorPrimaryVariant" > @color/lavender < /item > 
         < item name= "colorOnPrimary" > @color/white < /item > 
         < !-- Secondary brand color. -- > 
         < item name= "colorSecondary" > @color/teal_200 < /item > 
         < item name= "colorSecondaryVariant" > @color/teal_700 < /item > 
         < item name= "colorOnSecondary" > @color/black < /item > 
         < !-- Status bar color. -- > 
         < item name= "android:statusBarColor" > ?attr/colorPrimaryVariant < /item > 
         < !-- Customize your theme here. -- > 
Step 5: AndroidManifest.xml 
< ?xml version= "1.0"  encoding= "utf-8" ? > 
< manifest xmlns:android= "http://schemas.android.com/apk/res/android" 
    xmlns:tools= "http://schemas.android.com/tools" > 
        android:allowBackup= "true" 
        android:dataExtractionRules= "@xml/data_extraction_rules" 
        android:fullBackupContent= "@xml/backup_rules" 
        android:icon= "@mipmap/ic_launcher" 
        android:label= "@string/app_name" 
        android:roundIcon= "@mipmap/ic_launcher_round" 
        android:supportsRtl= "true" 
        android:theme= "@style/Theme.NavigationDrawer" 
            android:name= ".MainActivity" 
            android:theme= "@style/Theme.AppCompat.Light.NoActionBar" 
                 < action android:name= "android.intent.action.MAIN"  / > 
                 < category android:name= "android.intent.category.LAUNCHER"  / > 
                android:name= "android.app.lib_name" 
Step 6: Add Images and Vector Asset in Drawables Folder. 
I have added two images, the first is the logo image and the second is the header image.
Further, I have added five vector assets. Icon Name – Home, Settings, Info(About), Exit(Logout), Share.
Step 7: Create four blank fragments and name them as follows: 
HomeFragment, SettingsFragment, AboutFragment, ShareFragment.
Step 8: nav_menu .xml 
Right-click on res -> Android Resource Directory and select the menu then right-click on the menu directory and click on New -> Menu Resource File and name “nav_menu”.
<?xml version="1.0" encoding="utf-8"?> 
     xmlns:android = "http://schemas.android.com/apk/res/android" 
     xmlns:tools = "http://schemas.android.com/tools" 
     tools:showIn  =  "navigation_view" > 
         android:checkableBehavior = "single" > 
             android:id = "@+id/nav_home" 
             android:icon = "@drawable/nav_home" 
             android:id = "@+id/nav_settings" 
             android:icon = "@drawable/nav_settings" 
             android:title = "Settings" /> 
             android:id = "@+id/nav_share" 
             android:icon = "@drawable/nav_share" 
             android:id = "@+id/nav_about" 
             android:icon = "@drawable/nav_about" 
             android:title = "About Us" /> 
                 android:id = "@+id/nav_logout" 
                 android:icon = "@drawable/nav_logout" 
Step 9: nav_header.xml 
Right-click on layout -> Layout Resource File -> nav_header
<?xml version="1.0" encoding="utf-8"?> 
     xmlns:android = "http://schemas.android.com/apk/res/android" 
     android:orientation = "vertical" 
     android:layout_width = "match_parent" 
     android:layout_height = "176dp" 
     android:background = "@drawable/headerbkg" 
     android:theme = "@style/ThemeOverlay.AppCompat.Dark" > 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:src = "@drawable/aklogo" /> 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:text = "Android Knowledge" 
         android:textColor = "@color/white" 
         android:textStyle = "bold" /> 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:text = "contact@androidknowledge.com" 
         android:textColor = "@color/white" 
         android:layout_marginBottom = "16dp" /> 
Step 10: activity_main.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:context = ".MainActivity" > 
         android:layout_width = "match_parent" 
         android:layout_height = "match_parent" 
         android:orientation = "vertical" > 
         < androidx.appcompat.widget.Toolbar 
             android:layout_width = "match_parent" 
             android:layout_height = "56dp" 
             android:id = "@+id/toolbar" 
             android:background = "@color/lavender" 
             android:theme = "@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
             android:popupTheme = "@style/ThemeOverlay.AppCompat.Light" /> 
             android:layout_width = "match_parent" 
             android:layout_height = "match_parent" 
             android:id = "@+id/fragment_container" /> 
     < 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/lavender" 
         app:itemTextColor = "@color/lavender" /> 
</ androidx.drawerlayout.widget.DrawerLayout > 
Step 10: activity_main.xml OR XML CODR 
<? 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 :id ="@+id/drawerLayout"      android :layout_width ="match_parent"      android :layout_height ="match_parent"      android :padding ="10dp"      android :orientation ="vertical"      tools :context =".NavigationDrawer"      tools :openDrawer ="start" >     <RelativeLayout          android :layout_width ="match_parent"          android :layout_height ="wrap_content" >     <androidx.coordinatorlayout.widget.CoordinatorLayout          android :layout_width ="match_parent"          android :layout_height ="wrap_content"          android :id ="@+id/cordinate" >         <com.google.android.material.appbar.AppBarLayout              android :layout_width ="match_parent"              android :layout_height ="wrap_content" >             <com.google.android.material.appbar.MaterialToolbar                  android :layout_width ="match_parent"                  android :layout_height ="56dp"                  android :id ="@+id/toolbar"                  android :layout_marginTop ="50dp"                  android :elevation ="4dp"                  android :background ="@color/lavender"                  app :title ="Shamim"                  app :navigationIcon ="@drawable/baseline_dehaze_24"                  app :menu ="@menu/toolbaritem"                  android :theme ="@style/ThemeOverlay.AppCompat.Dark.ActionBar"                  android :popupTheme ="@style/ThemeOverlay.AppCompat.Light" />         </com.google.android.material.appbar.AppBarLayout>     </androidx.coordinatorlayout.widget.CoordinatorLayout>     <FrameLayout          android :layout_width ="match_parent"          android :layout_height ="match_parent"          android :background ="@color/lavender"          android :layout_below ="@+id/cordinate"          android :id ="@+id/frameLayout" />     </RelativeLayout>     <com.google.android.material.navigation.NavigationView          android :layout_width ="wrap_content"          android :layout_height ="match_parent"          android :id ="@+id/navigationView"          android :layout_gravity ="start"          app :headerLayout ="@layout/nav_header"          app :menu ="@menu/nav"          app :itemIconTint ="@color/lavender"          app :itemTextColor ="@color/lavender" /> </androidx.drawerlayout.widget.DrawerLayout> 
Step 11: All fragments.xml 
fragment_home.xml
<?xml version="1.0" encoding="utf-8"?> 
     xmlns:android = "http://schemas.android.com/apk/res/android" 
     xmlns:tools = "http://schemas.android.com/tools" 
     android:layout_width = "match_parent" 
     android:layout_height = "match_parent" 
     tools:context = ".HomeFragment" > 
     <!-- TODO: Update blank fragment layout --> 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:text = "Home Fragment" 
         android:layout_centerInParent = "true" 
         android:textColor = "@color/lavender" /> 
fragment_about.xml
<?xml version="1.0" encoding="utf-8"?> 
     xmlns:android = "http://schemas.android.com/apk/res/android" 
     xmlns:tools = "http://schemas.android.com/tools" 
     android:layout_width = "match_parent" 
     android:layout_height = "match_parent" 
     tools:context = ".AboutFragment" > 
     <!-- TODO: Update blank fragment layout --> 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:text = "About Us Fragment" 
         android:layout_centerInParent = "true" 
         android:textColor = "@color/lavender" /> 
fragment_settings.xml
<?xml version="1.0" encoding="utf-8"?> 
     xmlns:android = "http://schemas.android.com/apk/res/android" 
     xmlns:tools = "http://schemas.android.com/tools" 
     android:layout_width = "match_parent" 
     android:layout_height = "match_parent" 
     tools:context = ".SettingsFragment" > 
     <!-- TODO: Update blank fragment layout --> 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:text = "Settings Fragment" 
         android:layout_centerInParent = "true" 
         android:textColor = "@color/lavender" /> 
fragment_share.xml
<?xml version="1.0" encoding="utf-8"?> 
     xmlns:android = "http://schemas.android.com/apk/res/android" 
     xmlns:tools = "http://schemas.android.com/tools" 
     android:layout_width = "match_parent" 
     android:layout_height = "match_parent" 
     tools:context = ".ShareFragment" > 
     <!-- TODO: Update blank fragment layout --> 
         android:layout_width = "wrap_content" 
         android:layout_height = "wrap_content" 
         android:text = "Share Fragment" 
         android:layout_centerInParent = "true" 
         android:textColor = "@color/lavender" /> 
Step 12: Clear unnecessary code in all the Fragments.java 
Check our Youtube Video: Navigation Drawer Menu in Android Studio using Java. 
Step 13: MainActivity.java 
package  com.example.navigationdrawer ; 
import  androidx.annotation.NonNull ; 
import  androidx.appcompat.app.ActionBarDrawerToggle ; 
import  androidx.appcompat.app.AppCompatActivity ; 
import  androidx.appcompat.widget.Toolbar ; 
import  androidx.core.view.GravityCompat ; 
import  androidx.drawerlayout.widget.DrawerLayout ; 
import  android.os.Bundle ; 
import  android.view.MenuItem ; 
import  android.widget.Toast ; 
import  com.google.android.material.navigation.NavigationView ; 
public   class  MainActivity  extends  AppCompatActivity  implements  NavigationView. OnNavigationItemSelectedListener   { 
     private  DrawerLayout drawerLayout; 
     protected   void   onCreate ( Bundle savedInstanceState )   { 
         super . onCreate ( savedInstanceState ) ; 
         setContentView ( R. layout . activity_main ) ; 
       Toolbar toolbar =  findViewById ( R. id . toolbar ) ;  //Ignore red line errors 
        setSupportActionBar ( toolbar ) ; 
       drawerLayout =  findViewById ( R. id . drawer_layout ) ; 
       NavigationView navigationView =  findViewById ( R. id . nav_view ) ; 
       navigationView. setNavigationItemSelectedListener ( this ) ; 
        ActionBarDrawerToggle toggle =  new   ActionBarDrawerToggle ( this , drawerLayout, toolbar, R. string . open_nav , 
        drawerLayout. addDrawerListener ( toggle ) ; 
         if   ( savedInstanceState ==  null )   { 
             getSupportFragmentManager () . beginTransaction () . replace ( R. id . fragment_container ,  new   HomeFragment ()) . commit () ; 
            navigationView. setCheckedItem ( R. id . nav_home ) ; 
     public   boolean   onNavigationItemSelected ( @NonNull  MenuItem item )   { 
         switch   ( item. getItemId ())   { 
                 getSupportFragmentManager () . beginTransaction () . replace ( R. id . fragment_container ,  new   HomeFragment ()) . commit () ; 
                 getSupportFragmentManager () . beginTransaction () . replace ( R. id . fragment_container ,  new   SettingsFragment ()) . commit () ; 
                 getSupportFragmentManager () . beginTransaction () . replace ( R. id . fragment_container ,  new   ShareFragment ()) . commit () ; 
                 getSupportFragmentManager () . beginTransaction () . replace ( R. id . fragment_container ,  new   AboutFragment ()) . commit () ; 
                Toast. makeText ( this ,  "Logout!" , Toast. LENGTH_SHORT ) . show () ; 
        drawerLayout. closeDrawer ( GravityCompat. START ) ; 
     public   void   onBackPressed ()   { 
         if   ( drawerLayout. isDrawerOpen ( GravityCompat. START ))   { 
            drawerLayout. closeDrawer ( GravityCompat. START ) ; 
Min Java Uporer ta Na  Likhew Nicher ta Likhlew Hobe 
package  com.example.fragmentsexam; import  android.content.ClipData; import  android.media.RouteListingPreference; import  android.os.Bundle; import  android.view.MenuItem; import  android.widget.FrameLayout; import  android.widget.Toast; import  androidx.activity.EdgeToEdge; import  androidx.annotation.NonNull ; import  androidx.appcompat.app.ActionBarDrawerToggle; import  androidx.appcompat.app.AppCompatActivity; import  androidx.appcompat.widget.Toolbar; import  androidx.core.graphics.Insets; import  androidx.core.view.GravityCompat; import  androidx.core.view.ViewCompat; import  androidx.core.view.WindowInsetsCompat; import  androidx.drawerlayout.widget.DrawerLayout; import  androidx.fragment.app.FragmentManager; import  androidx.fragment.app.FragmentTransaction; import  com.google.android.material.appbar.MaterialToolbar; import  com.google.android.material.navigation.NavigationView; public class  NavigationDrawer extends  AppCompatActivity {     DrawerLayout drawerLayout ;      MaterialToolbar toolbar ;      FrameLayout frameLayout ;      NavigationView navigationView ;      @Override      protected void  onCreate (Bundle savedInstanceState) {         super .onCreate(savedInstanceState);          EdgeToEdge.enable (this );          setContentView(R.layout.navigation_drawer );          ViewCompat.setOnApplyWindowInsetsListener (findViewById(R.id.drawerLayout ),  (v,  insets) -> {             Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars ());              v.setPadding(systemBars.left ,  systemBars.top ,  systemBars.right ,  systemBars.bottom );             return  insets;          });          frameLayout =findViewById(R.id.frameLayout );          toolbar =findViewById(R.id.toolbar );          drawerLayout =findViewById(R.id.drawerLayout );         navigationView =findViewById(R.id.navigationView );         ActionBarDrawerToggle togglee=new  ActionBarDrawerToggle(NavigationDrawer.this,                 drawerLayout , toolbar , R.string.close_nav , R.string.open_nav );         drawerLayout .addDrawerListener(togglee);          navigationView .setNavigationItemSelectedListener(new  NavigationView.OnNavigationItemSelectedListener() {             @Override              public boolean  onNavigationItemSelected (@NonNull  MenuItem item) {                 if  (item.getItemId()==R.id.nav_home ){                     Toast.makeText (NavigationDrawer.this, "Home" , Toast.LENGTH_LONG ).show();                      Toast.makeText (NavigationDrawer.this, "Home" , Toast.LENGTH_LONG ).show();                      FragmentManager fragmentManager=getSupportFragmentManager();                      FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();                      fragmentTransaction.add(R.id.frameLayout ,new  Fastragment());                      fragmentTransaction.commit();                                           drawerLayout .closeDrawer(GravityCompat.START );                  }                 else if  (item.getItemId()==R.id.nav_about ){                     Toast.makeText (NavigationDrawer.this, "About" , Toast.LENGTH_LONG ).show();                      FragmentManager fragmentManager=getSupportFragmentManager();                      FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();                      fragmentTransaction.add(R.id.frameLayout ,new  SecoundFragment());                      fragmentTransaction.commit();                      drawerLayout .closeDrawer(GravityCompat.START );                  }                 return false;              }         });      } }
Output