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
45
votes
10 answers

Android DrawerLayout - No drawer view found with gravity

When I click on my drawer toggle I get the following exception: java.lang.IllegalArgumentException: No drawer view found with gravity LEFT This is my activity_drawer.xml:
Tobias
  • 4,921
  • 4
  • 31
  • 40
44
votes
6 answers

Switch between Fragments with onNavigationItemSelected in new Navigation Drawer Activity template (Android Studio 1.4 onward)

IntelliJ has made changes to the Navigation Drawer template Activity in Android Studio with fewer lines of code in the Activity class. The new Activity class looks like this: public class MainActivity extends AppCompatActivity implements…
Ojonugwa Jude Ochalifu
  • 26,627
  • 26
  • 120
  • 132
44
votes
6 answers

How can I change separator color in NavigationView?

I'm trying to use NavigationView to implement NavigationDrawer. I have added the separator by setting group id in menu. However I can't see the separator. I guess it is because the separator color is same as the background. So I want to change the…
44
votes
2 answers

Change drawer icon back to back arrow

I'm using the new DrawerLayout to have side navigation. I'm using the drawer icon (the 'hamburger') like this: @Override protected void onStart() { super.onStart(); mDrawerLayout = (DrawerLayout)…
nhaarman
  • 98,571
  • 55
  • 246
  • 278
44
votes
3 answers

Set Background Color of Navigation Drawer

I wanted to set the background color of my Navigation drawer in java but it seems as setBackgroundColor and all similar methods have no effect. Only the XML line android:background="@color/mycolor" is working. If remove the xml line and try one of…
mike.b93
  • 1,989
  • 2
  • 18
  • 31
43
votes
7 answers

How to open Navigation Drawer with no actionbar, open with just a button

I have a navigation bar without any actionbar (I don't want an actionbar). I'm trying to make it so that I have a button that can open the navigation drawer. I know there's a method called openDrawer for the DrawerLayout…
CynthiaDDurazo
  • 503
  • 1
  • 4
  • 11
42
votes
16 answers

Full width Navigation Drawer

I'd like to create a full width navigation drawer. Setting layout_width to match_parent on @+id/left_drawer yields in width of about 80% of screen space. This seems to be the standard behavior. Do I have to override onMeasure() of DrawerLayout? My…
Martin
  • 1,877
  • 5
  • 21
  • 37
40
votes
4 answers

Android on Drawer Closed Listener

I have an application using navigation drawer that provides list of locations. In the drawer, there are several options (like choosing country, city, etc) that user can setup before showing the corresponding list in the main activity. Is there any…
Ren
  • 445
  • 1
  • 4
  • 9
39
votes
5 answers

How to programmatically add a submenu item to the new material design android support library

I am trying to add new menu items to a submenu in the new Material Design drawer panel.
Moritur
  • 1,651
  • 1
  • 18
  • 31
39
votes
10 answers

How to replace the hamburger icon used for ActionBarToggle on Android Toolbar with a custom drawable?

I have implemented a basic ActionBarDrawerToggle using the new Toolbar in Android 5.0. However, I am unable to figure out how to change the default hamburger icon that is supplied. From the android documentation it says that "the given Activity will…
jet
  • 415
  • 1
  • 4
  • 8
39
votes
10 answers

Changing Navigation drawer icon on action bar android

I have created a NavigationDrawer in my app using the ActionBar. As showed in the picture above I want to change the NavigationDrawer toggle button icon to something I want. How can I change it? Here is my…
user3713706
  • 1,243
  • 4
  • 15
  • 18
39
votes
8 answers

ClassCastException android.widget.FrameLayout$LayoutParams to android.support.v4.widget.DrawerLayout$LayoutParams

I'm working on the Navigation Drawer for Android. As per my requirement I was to display gridview and listview of items in the navigation drawer. I have created a linearLayout in the layout xml file and placed the two widgets(Grid view, and…
38
votes
7 answers

Android Api 23 Change Navigation View headerLayout textview

I am testing the Navigation Drawer sample project in android and i have a problem setting the text in navigation view profile header. This is my code: MainActivity.java @Override protected void onCreate(Bundle savedInstanceState) { …
user3065901
  • 4,678
  • 11
  • 30
  • 52
37
votes
11 answers

DrawerLayout must be measured with MeasureSpec.EXACTLY error

I am trying to implement a Navigation drawer, but I keep getting this error. I saw the similar questions but did not work for me. I have the following layout activity_main2.xml:
Ismail Rubad
  • 1,458
  • 2
  • 13
  • 27
37
votes
9 answers

push activity on the right when open drawer

I have implemented drawerlayout which slides from the right but it does not shift the activity the right like facebook does (See below image). How do I push the current activity to the right side when user taps on opendrawer button like in the above…
jason
  • 3,932
  • 11
  • 52
  • 123