Questions tagged [navigation-drawer]

Navigation Drawer in a mobile application is the side panel which slides out from the edge of the screen and displays the navigation menu of the application. Use this tag for programming questions related to navigation drawers only. General UX questions and other opinion based questions related to navigation drawers are not on topic for Stack Overflow.

Navigation Drawer in Android

The navigation drawer is commonly used as a "slide-in" navigation menu in Android applications. It slides in from the edge of the screen and displays a list of the application's main navigation options.

The drawer slides on top of the content instead of the content sliding away. With this, one can access any top level content from anywhere in the app and allows you to create a flatter navigation structure. It also has an action bar at the top. Lower versions also support it through support library.

Documentation

  • Design docs can be found here.
  • Developer docs can be found here.
  • DrawerLayout API reference can be found here.

Related tags:

5793 questions
36
votes
5 answers

DrawerLayout getting stuck on swipe

I am playing around with DrawerLayout and I am encountering an issue. Basically sometimes when i swipe from the edge of the screen the DrawerLayout will get stuck until i lift my finger off the screen (See screenshot below) I am not sure what is up,…
thunderousNinja
  • 3,510
  • 9
  • 37
  • 49
35
votes
13 answers

getting undefined is not a function (evaluating '(0,_reactNavigation.stacknavigator)') in drawer navigation

In my application I need drawer navigation, for that I am using sample code from this. I have integrated everything in my application, but getting the following error undefined is not a function (evaluating …
rams
  • 1,558
  • 7
  • 25
  • 48
34
votes
3 answers

How to add an item to a menu group in NavigationView

In a word game for Android I currently have a hardcoded menu inflated from left_drawer_menu.xml and consisting of 3 groups (my turn, opponent turn and finally other stuff): mLeftDrawer = (NavigationView)…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
34
votes
6 answers

Navigation drawer, handling the back button to go to previous fragments?

I'm using the built-in navigation drawer to run my app. I can't quite figure out how to handle the back button. When it's pressed I want it to load the very first fragment again. Fragment1. So when the app launches you see Fragment1 launched. They…
34
votes
2 answers

Set drag margin for Android Navigation Drawer

I am using the new Navigation Drawer in my app. It is great except I have not found an easy way to set how the drawer is open. The default behavior is drag from the left edge of the screen to open. This is fine, unless the phone/table has a case…
Patrick Jackson
  • 18,766
  • 22
  • 81
  • 141
33
votes
3 answers

Add Navigation Drawer to an existing activity

I have an app I am writing and it is already contains a lot of code, I decided I want to add a navigation drawer to the main activity toolbar but I don't know how to do it without creating a new navigation drawer project and copy my whole project to…
user7415791
  • 449
  • 1
  • 7
  • 11
32
votes
6 answers

How to set shared checkable behavior across all groups in NavigationView?

I've created two groups with unique ids (I need a divider) and they both have checkableBehavior set to single. This allows multiple items from different groups to be checked at once, and that's exactly what I'm trying to avoid. I'd like to have one…
32
votes
2 answers

How to implement a DrawerLayout with a visible handle

I have successfully implemented a NavigationDrawer for my application. My app displays a drawer that opens on the left of the screen. My problem is I need to add a button on the left. That button might be clicked or swiped to open the left drawer.…
Armel Larcier
  • 15,747
  • 7
  • 68
  • 89
31
votes
3 answers

Navigation Component, Control when to show hamburger or back icon

I have the following Activity class MainActivity : AppCompatActivity() { private lateinit var drawerLayout: androidx.drawerlayout.widget.DrawerLayout override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) …
31
votes
1 answer

Android: Is it better to create a new fragment every time a navigation drawer item is clicked, or load up previously created fragments?

I am implementing the standard navigation drawer pattern for android, with about 10 fragments the user can navigate to from the drawer. Currently, I am creating a new Fragment every time a different navigation drawer item is clicked like so: // When…
krishan711
  • 873
  • 1
  • 12
  • 27
30
votes
6 answers

native.createnavigator factory is not a function

I am going to design a Drawer navigation in my project. I installed that by this command: npm install @react-navigation/drawer Then imported that into App.js import { createDrawerNavigator } from '@react-navigation/drawer'; import {…
roz333
  • 695
  • 2
  • 18
  • 30
30
votes
7 answers

How to change navigation drawer font?

I want to use my own font for navigation drawer in android.I use the library comes with android studio according to this answer: https://stackoverflow.com/a/23632492/4393226. But I don't know how to change the font and make it RTL. I searched a lot…
Amir H
  • 1,116
  • 1
  • 11
  • 25
30
votes
6 answers
29
votes
5 answers

How to change the text and icon color of selected menu item on Navigation Drawer programmatically using java

I am a beginner in Android Development. Using android's default Navigation drawer activity I am developing an application. One of the requirements of this app is to change the background colors of layouts (including navigation drawer header color)…
Kuldeep Kumar
  • 905
  • 3
  • 9
  • 22
29
votes
8 answers

onClick event in navigation drawer

I have made a navigation drawer in Android in which I want to implement onClick for it. This is my main activity: public class MainActivity extends AppCompatActivity { private DrawerLayout mDrawerLayout; private ActionBarDrawerToggle…
Alpit Anand
  • 1,213
  • 3
  • 21
  • 37