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
29
votes
5 answers

Android set navigation drawer list to open exact half of the screen for all device screen

I want to open the drawerlist to the half of the screen for all different device. i tried hard coded values for layout_margineleft 200dp or 100dp to the drawerlist. but it doesn't work in all device it different from device to device. so how can i…
Mayur Raval
  • 3,250
  • 6
  • 34
  • 57
29
votes
5 answers

Navigation Drawer Icon (ic_drawer) not showing

I am implementing a navigation drawer for my app. Now it works perfectly except for one small glitch. When I set the Navigation Drawer Icon (ic_drawer) to replace the regular "HomeAsUp" caret icon, I still get the arrow. The Nav Drawer icon does not…
Adifyr
  • 2,649
  • 7
  • 41
  • 62
29
votes
7 answers

Hide ActionBar MenuItems when Navigation Drawer slides for any amount

I'm trying to implement a Navigation Drawer that hides the menu items in the ActionBar whenever the drawer is opened. I am following google's documentation, however their code does not produce the expected…
Synergy807
  • 523
  • 2
  • 6
  • 18
28
votes
5 answers

Android - Navigation View item menu background color

i try to change color of my item Navigation View menu : styles.xml @drawable/activated_background activated_background.xml
Emmanuel Loisance
  • 706
  • 1
  • 12
  • 22
28
votes
4 answers

Google's NavigationDrawer not drawing correctly over map

I'm having this issue with Google's NavigationDrawer not drawing correctly over the map when I pull it out from the side of the screen, it's being drawn under the map instead of over it, when closing it from already being open it is shown correctly.…
27
votes
5 answers

Navigation graph with multiple top level destinations

I am implementing an android app (in Kotlin, but that is not relevant to the Problem) in my free time and I try to use android jetpack and new libraries. I have a single Activity with a navigation drawer. I try to follow the sample sunflower app. It…
findusl
  • 2,454
  • 8
  • 32
  • 51
27
votes
4 answers

Cannot resolve method getActivity()

I am new to Android and learning to create fragments in Android by following this example: Fragment Navigation Drawer The code between Navigating between Menu Items and Add Navigation Header consists a method getActivity(). As the author didn't…
Akki
  • 1,221
  • 3
  • 14
  • 33
27
votes
6 answers

OnClick for navigation drawer header not working

I have a navigation drawer in my app which contains a header and some list items. The header has a textview which i want to make clickable but I am not able to do it. To get the id of this textview I used the following code, since it is in a…
varunkr
  • 5,364
  • 11
  • 50
  • 99
27
votes
4 answers

Navigation Drawer - what does syncState() do and why it should be called inside onPostCreate()?

I am learning to create navigation drawer in Android. While reading this, I can't understand following code: @Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state…
Krupal Shah
  • 8,949
  • 11
  • 57
  • 93
27
votes
12 answers

Hide navigation drawer when user presses back button

I've followed Google's official developer tutorials here to create a navigation drawer. At the moment, everything works fine, except for when the user uses the native back button Android provides at the bottom of the screen (along with the home and…
pez
  • 3,859
  • 12
  • 40
  • 72
27
votes
6 answers

How to open navigation drawer on button click in main fragment?

I have made an app with one activity which uses a navigation drawer to open a number of different fragments. I have the actionbar drawertoggle, but it is not very visible. If I place a button in the onCreateView in my main fragment(the fragment that…
user2729524
  • 281
  • 1
  • 3
  • 5
27
votes
2 answers

Why does DrawerLayout sometimes glitch upon opening?

I have followed the tutorial Navigation Drawer and everything works like a charm except for a small glitch. I'll try to explain it as much as possible, and if it still isn't clear, I'll try to upload a video of the problem. Problem happens when…
LuckyMe
  • 3,820
  • 2
  • 27
  • 35
26
votes
9 answers

Android Navigation Drawer over the tabs

I am using the new navigation drawer available from the support library. When using the drawer along with tabs, the drawer menu is getting displayed below the tabs as shown below. How can i make sure the drawer menu is shown on the tabs. (It should…
suresh cheemalamudi
  • 6,190
  • 11
  • 49
  • 67
25
votes
1 answer

Add badge counter to hamburger navigation menu icon in Android

My question is the same as this question (which is not a duplicate of this question). The only answer to that question does not work for me as, rather than changing the default hamburger icon to the left of the activity's title, it just adds an…
25
votes
1 answer

How to make the Contextual ActionMode Bar overlay the appcompat-v7 Toolbar but not the navigation drawer?

I have an activity with an app bar and a navigation drawer. The app bar is implemented using the new Toolbar class from appcompat-v7 library version 21.+, and the navigation drawer is displayed in front of it. The activity contains a list view with…