How to customize the back button on ActionBar

后端 未结 9 1241
抹茶落季
抹茶落季 2020-11-22 17:12

I have been able to customize the action bar\'s background, logo image and text color using suggestions from these:
Android: How to change the ActionBar "Home"

9条回答
  •  爱一瞬间的悲伤
    2020-11-22 17:47

    I have checked the question. Here is the steps that I follow. The source code is hosted on GitHub: https://github.com/jiahaoliuliu/sherlockActionBarLab

    Override the actual style for the pre-v11 devices.

    Copy and paste the follow code in the file styles.xml of the default values folder.

    
        
    
    

    Note that the parent could be changed to any Sherlock theme.

    Override the actual style for the v11+ devices.

    On the same folder where the folder values is, create a new folder called values-v11. Android will automatically look for the content of this folder for devices with API or above.

    Create a new file called styles.xml and paste the follow code into the file:

    
    
        
    
    

    Note tha the name of the style must be the same as the file in the default values folder and instead of the item homeAsUpIndicator, it is called android:homeAsUpIndicator.

    The item issue is because for devices with API 11 or above, Sherlock Action Bar use the default Action Bar which comes with Android, which the key name is android:homeAsUpIndicator. But for the devices with API 10 or lower, Sherlock Action Bar uses its own ActionBar, which the home as up indicator is called simple "homeAsUpIndicator".

    Use the new theme in the manifest

    Replace the theme for the application/activity in the AndroidManifest file:

    
    

提交回复
热议问题