Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Hamburger icon is an arrow on 4.x

I've implemented the ActionBarDrawerToggle with the hamburger icon (support library v7), but for some reason the toggle only displays a 'back' arrow on devices not running 5.0 (I have confirmed this for all 4.x versions). Is this normal behaviour?

The arrow looks like this:

The arrow

Now the arrow icon doesn't change. It's the same when the navigation drawer is pulled out, or when it is in collapsed mode.

This is how I initalize the drawertoggle etc.

// drawer toggle
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
        R.string.drawer_open, R.string.drawer_close);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);

EDIT

For some clarification. I am using the old regular ActionBar, not the Toolbar. The hamburger icon DOES show on 5.0 devices but not on < 5.0. Should I use the toolbar to fix this problem?

like image 414
Tim Kranen Avatar asked Nov 09 '22 15:11

Tim Kranen


1 Answers

In order to get the hamburger icon this piece of code below is enough

Toolbar toolbar =(Toolbar)findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

it's showing back button because you are using the method setDisplayHomeAsUpEnabled(true);

Check out the official reference Click here

like image 164
silverFoxA Avatar answered Nov 14 '22 22:11

silverFoxA