Search code examples
androidactionbarsherlock

I want to change the custom back button in sherlock action bar and remove app icon


I dont like the default back button that comes with action bars they look rather to tiny for my liking. I trying to fix a bigger and more descriptive button like the one used in the WeChat Mobile App. please any body with an Idea.

I tried this below but did not work

<item name="android:homeAsUpIndicator">@drawable/back</item>  //Put in my style

The the one below in my code

 ActionBar actionBar = getSupportActionBar();
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
      //  actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setDisplayUseLogoEnabled(true);

But did not work. the image that I kept in my drawable is not show. My app icon keeps show on the action bar which I dont want. and the back button is not working. Please any idea.


Solution

  • try this :

    <style name="YourTheme" parent="@style/Theme.Sherlock.Light.DarkActionBar">
        <item name="homeAsUpIndicator">@drawable/new_indicator</item>
        <item name="android:homeAsUpIndicator">@drawable/new_indicator</item>
    </style>
    

    And new_indicator xml file in drawable folder: new_indicator.xml

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <item
        android:left="0dp"
        android:right="5dp">
        <bitmap android:src="@drawable/indicator" /> <!-- this is your desired image -->
    </item>
    
    </layer-list>