Change icon of ActionBar with ActionBarDrawerToggle v7

Here is another problem that a lot of us have faced : Changing the ActionBar Icon when using "android.support.v7.app.ActionBarDrawerToggle" instead of the deprecated "android.support.v4.app.ActionBarDrawerToggle"

After a lot of researches and readings here is the solution for anyone who needs it.

In your :


1
2
3
@Override
    protected void onCreate(Bundle savedInstanceState) {
    }


Call :

1
2
3
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_drawer);

So you have something like this :


1
2
3 
4
5
6
@Override
    protected void onCreate(Bundle savedInstanceState) {
       getSupportActionBar().setHomeButtonEnabled(true);
       getSupportActionBar().setDisplayHomeAsUpEnabled(true);
       getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_drawer);
    }

And that's it again.
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

1 comments:

  1. searched the net ,nothing else seemed to work
    so this is fabulous , thanks

    ReplyDelete

Leave your Comment

Powered by Blogger.