2

I want to have a Hamburger icon on my activity without the action bar. I have seen examples to do this with transparent action bar but i don't want it to be transparent one. I actually do want to add the action bar and if i click the hamburger icon it should show the Navigation Drawer. The layout is similar to Uber Android app. For reference i am also posting an image with red marked. Please help me to implement the same.enter image description here

sam
  • 1,800
  • 1
  • 25
  • 47

2 Answers2

8

Just add a view on top|left corner of root view and on click that view just open navigation drawer

DrawerLayout drawer = findViewById(R.id.drawer_layout);

if (!drawer.isDrawerOpen(GravityCompat.START)) {
    drawer.openDrawer(GravityCompat.START);
} else {
    drawer.closeDrawer(GravityCompat.START);
}
sam
  • 1,800
  • 1
  • 25
  • 47
Salman Aziz
  • 191
  • 4
2
<?xml version="1.0" encoding="UTF-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1600"
    android:fromDegrees="0"
    android:interpolator="@android:anim/linear_interpolator"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="1"
    android:toDegrees="360" />

Uber has transparent actionBar or toolbar... you can achieve that by both ways

  • Keeping your icon on the transparent actionbar/toolbar ... go through this link .. Material Design Transparent ActionBar
  • Without using actionbar just placing the icon and opening the drawer at its click.. and handling the rotating animation at click and then changing the hamburger icon to back button at the animation end.. rotate anim like this at onClick of icon..
Vidhi Dave
  • 5,614
  • 2
  • 33
  • 55
Santanu Sur
  • 10,997
  • 7
  • 33
  • 52