Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Drawer without Actionbar

I searched many sites (stackoverflow as well) but couldn't understand how to implement the navigation drawer without the action bar. I know that this question has already been asked here but it doesn't have a proper explanation and code. I am a beginner in android development so can anyone please explain me with code How to make a navigation drawer without an action bar

Thanks in advance!

like image 905
Chinmay Dabke Avatar asked Jan 07 '14 12:01

Chinmay Dabke


People also ask

How to add navigation drawer in existing android app?

To add a navigation drawer, first declare a DrawerLayout as the root view. Inside the DrawerLayout , add a layout for the main UI content and another view that contains the contents of the navigation drawer.

How to use navigation drawer in android?

Android Navigation Drawer is a sliding left menu that is used to display the important links in the application. Navigation drawer makes it easy to navigate to and fro between those links. It's not visible by default and it needs to opened either by sliding from left or clicking its icon in the ActionBar.


2 Answers

Just add your DrawerLayout like @mohan did, then if you have a button or something you tap on and want to open the drawer, just do like this :

drawer.openDrawer(Gravity.LEFT); 

and to close :

drawer.closeDrawer(Gravity.LEFT); 
like image 153
Mehdiway Avatar answered Sep 22 '22 11:09

Mehdiway


Starting from the Sample Android NavigationDrawer app:

  1. Use the Activity theme: Theme.NoTitleBar
  2. Erase all the ActionBar references in the code
  3. Create a button and in the clickListener call:

    drawer.openDrawer(Gravity.LEFT);

like image 36
Kim Sant Avatar answered Sep 19 '22 11:09

Kim Sant