Search code examples
androidnavigation-drawerandroid-toolbardrawerlayout

Can I remove the Hamburger (drawer navigation icon) from the toolbar, removing the area of it (rectangle)?


I want to remove the hamburger and the rectangle area of it, but I just can't.

A lot of answers out there are saying to use "setDrawerIndicatorEnabled(false)", but I think this is not what I want, or if it is, I'm not using correctly.

When the indicator is disabled, the ActionBar will revert to displaying the home-as-up indicator provided by the Activity's theme in the android.R.attr.homeAsUpIndicator attribute instead of the animated drawer glyph.

The thing is, I want to remove it, not just show the navigation arrow.


Solution

  • The sole purpose of an ActionBarDrawerToggle is to enable that button to open/close the drawer of a DrawerLayout with a click. If you don't want that functionality, you can just remove the ActionBarDrawerToggle. The user will still be able to drag the drawer per usual, and you can still open/close it programmatically with the appropriate DrawerLayout#openDrawer() and DrawerLayout#closeDrawer*() methods.

    If you've also used another method that enables a navigation/up button - e.g., ActionBar#setDisplayHomeAsUpEnabled() or Toolbar#setNavigationIcon() - you'll need to remove that, as well, to completely get rid of the button.