Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the back button on ActionBar

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" Icon to be something other than the app icon?
ActionBar text color
ActionBar background image

The last piece I want to customize is the back button image. It's grey by default and I would like it to be white. Either changing the color, specifying a drawable or simply making it transparent (and adding the chevron to my customized logo image) would work. How do I go about that?

like image 708
Sunil Gowda Avatar asked Feb 12 '12 20:02

Sunil Gowda


People also ask

How do I customize my action bar?

This example demonstrate about how to create a custom action bar in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do you display action bar back button on all versions of Android?

ActionBar actionBar = getActionBar(); actionBar. setHomeButtonEnabled(true);


1 Answers

The "up" affordance indicator is provided by a drawable specified in the homeAsUpIndicator attribute of the theme. To override it with your own custom version it would be something like this:

<style name="Theme.MyFancyTheme" parent="android:Theme.Holo">     <item name="android:homeAsUpIndicator">@drawable/my_fancy_up_indicator</item> </style> 

If you are supporting pre-3.0 with your application be sure you put this version of the custom theme in values-v11 or similar.

like image 89
Jake Wharton Avatar answered Sep 21 '22 06:09

Jake Wharton