title: How to use Navigation Drawer and Bottom Navigation simultaneously - Navigation Architecture Component
body: <p>I have screen like below which contain a navigation drawer and bottom navigation on same screen:</p>
  <p><a href="https://i.stack.imgur.com/Wv4pO.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Wv4pO.jpg" alt="app screen" /></a></p>
  <p>I am using Jetpack Navigation Architecture Component.</p>
  <p><strong>Current issue and What I have tried?</strong></p>
  <p>Clicking on the 2nd and 3rd bottom nav item shows back arrow on toolbar?</p>
  <p>Tried: setting fragments associated with 2nd and 3rd bottom nav to top level destinations</p>
  <pre><code>appBarConfig = AppBarConfiguration(setOf(R.layout.fragment_star, R.layout.fragment_stats, R.layout.fragment_user))
  </code></pre>
  <p>instead of</p>
  <pre><code>appBarConfig = AppBarConfiguration(navController.graph, drawerLayout)
  </code></pre>
  <p>Did not worked.</p>
  <p>Any help highly appreciated!</p>
  <hr />
  <p><strong>My code look like below.</strong></p>
  <p><strong>activity_main.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
  
      &lt;androidx.drawerlayout.widget.DrawerLayout
          android:id=&quot;@+id/drawerLayout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:fitsSystemWindows=&quot;true&quot;&gt;
  
  
          &lt;LinearLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:orientation=&quot;vertical&quot;&gt;
  
              &lt;androidx.appcompat.widget.Toolbar
                  android:id=&quot;@+id/toolbar&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;?attr/actionBarSize&quot;
                  android:background=&quot;?attr/colorPrimary&quot;
                  app:theme=&quot;@style/ThemeOverlay.AppCompat.Dark.ActionBar&quot;/&gt;
  
              &lt;fragment
                  android:id=&quot;@+id/navHostFragment&quot;
                  android:name=&quot;androidx.navigation.fragment.NavHostFragment&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;0dp&quot;
                  android:layout_weight=&quot;1&quot;
                  app:defaultNavHost=&quot;true&quot;
                  app:navGraph=&quot;@navigation/nav_graph&quot; /&gt;
  
              &lt;com.google.android.material.bottomnavigation.BottomNavigationView
                  android:id=&quot;@+id/bottomNav&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:layout_gravity=&quot;bottom&quot;
                  android:background=&quot;?android:attr/windowBackground&quot;
                  app:menu=&quot;@menu/menu_bottom&quot; /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;!-- gives navDrawer material look--&gt;
          &lt;com.google.android.material.navigation.NavigationView
              android:id=&quot;@+id/navView&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;match_parent&quot;
              android:layout_gravity=&quot;start&quot;
              app:menu=&quot;@menu/nav_drawer_menu&quot;
              app:headerLayout=&quot;@layout/nav_header&quot;
              android:fitsSystemWindows=&quot;true&quot;
              /&gt;
      &lt;/androidx.drawerlayout.widget.DrawerLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p><strong>menu_bottom.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
  
      &lt;item
          android:id=&quot;@+id/starFragment&quot;
          android:icon=&quot;@drawable/ic_star_green_48dp&quot;
          android:title=&quot;@string/bottom_nav_title_star&quot;/&gt;
  
      &lt;item
          android:id=&quot;@+id/statsFragment&quot;
          android:icon=&quot;@drawable/ic_stats_green_48dp&quot;
          android:title=&quot;@string/bottom_nav_title_stats&quot;/&gt;
  
      &lt;item
          android:id=&quot;@+id/userFragment&quot;
          android:icon=&quot;@drawable/ic_user_green_48dp&quot;
          android:title=&quot;@string/bottom_nav_title_user&quot;/&gt;
  
  &lt;/menu&gt;
  </code></pre>
  <p><strong>nav_graph.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
              xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
              xmlns:tools=&quot;http://schemas.android.com/tools&quot; android:id=&quot;@+id/nav_graph_main&quot;
              app:startDestination=&quot;@id/starFragment&quot;&gt;
  
      &lt;fragment
          android:id=&quot;@+id/starFragment&quot;
          android:name=&quot;com.example.app.ui.StarrFragment&quot;
          android:label=&quot;Star&quot;
          tools:layout=&quot;@layout/fragment_star&quot;&gt;
      &lt;/fragment&gt;
      &lt;fragment
          android:id=&quot;@+id/statsFragment&quot;
          android:name=&quot;com.example.app.StatsFragment&quot;
          android:label=&quot;fragment_stats&quot;
          tools:layout=&quot;@layout/fragment_stats&quot; /&gt;
      &lt;fragment
          android:id=&quot;@+id/userFragment&quot;
          android:name=&quot;com.example.app.UserFragment&quot;
          android:label=&quot;fragment_user&quot;
          tools:layout=&quot;@layout/fragment_user&quot; /&gt;
  &lt;/navigation&gt;
  </code></pre>
  <p><strong>ActivityMain.kt</strong></p>
  <pre><code>class MainActivity : AppCompatActivity() {
  
      private lateinit var drawerLayout: DrawerLayout
      private lateinit var appBarConfig: AppBarConfiguration
      private lateinit var navController: NavController
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
          val binding = DataBindingUtil.setContentView&lt;ActivityMainBinding&gt;(this, R.layout.activity_main)
          setSupportActionBar(toolbar)
  
          drawerLayout = binding.drawerLayout
          navController = this.findNavController(R.id.navHostFragment)
  
          binding.bottomNav.setupWithNavController(navController)
  
          NavigationUI.setupActionBarWithNavController(this, navController, drawerLayout)
          appBarConfig = AppBarConfiguration(navController.graph, drawerLayout)
  
  
          // lock drawer when not in start destination
          navController.addOnDestinationChangedListener { nc, nd, _ -&gt;
  
              if(nd.id == nc.graph.startDestination){
                  drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED)
              }
              else{
                  drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
              }
          }
  
           NavigationUI.setupWithNavController(binding.navView, navController)
      }
  
      override fun onSupportNavigateUp(): Boolean {
  
          // replace navigation up button with nav drawer button when on start destination
          return NavigationUI.navigateUp(navController, appBarConfig)
  
      }
  }
  </code></pre>