Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toolbar Navigation Hamburger Icon missing

I'm looking for a way to display the hamburger icon whitout using the Drawer/DrawerToggle and use the default icon included in Android enter image description here

By setting getSupportActionBar().setDisplayHomeAsUpEnabled(true); it display the back arrow but not the hambuerger. Other post on Stackoverflow (like this or this) use the DrawerLayout or a custom drawable. I cannot find the vector or png for the hamburger icon on the Android source.

Do you know how can I find the original hamburger icon in android/support library? (or how to displayed it)

Note: Vector and png can be found on google.com/design website : http://www.google.com/design/spec/resources/sticker-sheets-icons.html#

In my activity

mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true);  mToolbar.setNavigationOnClickListener(new View.OnClickListener() {     @Override     public void onClick(View v) {         Log.d(LOG_TAG, "navigation clicked");     } }); 

Layout file

<android.support.v7.widget.Toolbar     android:id="@+id/toolbar"     android:layout_height="wrap_content"     android:layout_width="match_parent"     android:minHeight="?attr/actionBarSize"     android:background="?attr/colorPrimary"     app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/> 

Styles.xml

<!-- Base application theme. --> <style name="Theme.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">       <item name="colorPrimary">@color/primaryDef</item>     <item name="colorPrimaryDark">@color/primaryDarkDef</item>     <item name="colorAccent">@color/primaryDef</item>      <!-- Remove the actionbar shadow-->     <item name="android:windowContentOverlay">@null</item> </style> 
like image 205
Hugo Gresse Avatar asked Jan 21 '15 16:01

Hugo Gresse


People also ask

Where is the hamburger menu icon?

When browsing websites, you've likely noticed the triple bar icon located at the top left or right corner of a web page. This icon is known as the hamburger icon, and it's used to store navigation options.

Where is the hamburger tab?

Hamburger buttons are usually placed in the top corner of the user interface.

Where is the Google hamburger menu?

Yes, Google has eliminated the Hamburger menu, which sat in the top left corner of the screen. The Hamburger menu was denoted by three tiny vertical lines in the top left corner. But the new design has removed the button which was the go-to button settings, logging out, and more.


2 Answers

If you want to use the same drawer as lollipop then let me tell you that's not a static image. That image is drawn in real time by a class called DrawerArrowDrawableToggle. So there is no "hamburger" icon for that.

However if you want the hamburger icon with no animation you can find it here:

https://material.io/tools/icons/?icon=menu&style=baseline

enter image description here

like image 124
Pedro Oliveira Avatar answered Oct 18 '22 08:10

Pedro Oliveira


To have an animated hamburger icon you should use DrawerLayout with ActionBarDrawerToggle and enable the icon for the ActionBar and for the ActionBarDrawerToggle.

Example:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle mDrawerToggle;  setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar();  if (actionBar != null) {    actionBar.setDisplayHomeAsUpEnabled(true);    mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.hello_world, R.string.hello_world)    {        public void onDrawerClosed(View view)       {          supportInvalidateOptionsMenu();          //drawerOpened = false;       }        public void onDrawerOpened(View drawerView)       {          supportInvalidateOptionsMenu();          //drawerOpened = true;       }    };    mDrawerToggle.setDrawerIndicatorEnabled(true);    drawerLayout.setDrawerListener(mDrawerToggle);    mDrawerToggle.syncState(); } 

Also, you need to add these methods to your Activity:

@Override protected void onPostCreate(Bundle savedInstanceState) {     super.onPostCreate(savedInstanceState);     mDrawerToggle.syncState(); }  @Override public void onConfigurationChanged(Configuration newConfig) {     super.onConfigurationChanged(newConfig);     mDrawerToggle.onConfigurationChanged(newConfig); } 
like image 22
mohax Avatar answered Oct 18 '22 10:10

mohax