Search code examples
javaandroidandroid-actionbaractionbarsherlock

ActionBarSherlock custom NavigationDrawer icon


I'm implementing NavigationDrawer with ActionBarSherlock and now I'm trying to implement custom icon for opening and closing the drawer. I already set my own icon (white) but I'm not able to get rid of that grey default icon.

in onCreateOptionsMenu I'm doing this:

getSupportActionBar().setDisplayShowTitleEnabled(false); // does not display activity title
getSupportActionBar().setBackgroundDrawable(
        getResources().getDrawable(R.drawable.actionbar_background)); // blue background 
getSupportActionBar().setIcon(R.drawable.side_menu_button); // white icon

The picture shows difference when navigation drawer is closed (first) and open (second picture).

Is there any way to do it programmatically? Or is there even some way to do it? I hope it is.

Thank you.

EDIT: This is what I'm trying to achieve:

enter image description here


Solution

  • What you are currently doing is setting the icon on the ActionBar, which is different from setting the icon of the ActionBarDrawerToggle, which is what you want to be dealing with. If you look at the documentation (http://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html) and find the constructor, you'll see there's a place to specify a custom Drawable to be used by the toggle.