18

How do I change the actionbar's up arrow. I am using the action bar in android not ABS or actionbarcompat. Is there a way to change the color /image of the action bar's up arrow ?

enter image description here

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Rasmus
  • 8,248
  • 12
  • 48
  • 72

3 Answers3

34

The answer is provided by Jake Wharton in How to customize the back button on ActionBar

<style name="Theme.MyTheme" parent="android:Theme.Holo">
    <item name="android:homeAsUpIndicator">@drawable/my_up_indicator</item>
</style>
Community
  • 1
  • 1
mmBs
  • 8,421
  • 6
  • 38
  • 46
6

If you are using Toolbar, you can change the color by just changing the theme. You only have to change the style of the toolbar

app:theme="@style/ThemeOverlay.AppCompat.Light"

app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

If you are using a dark.actionBar your back button is going to be white else if you are using light actionbar theme it is going to be black.

Update: If you want to modify the color as you wish (other then black or white) you can define a new style, parent one of the above themes and set colorControlNormal or android:textColorSecondary values to your desired color.

Oguz Ozcan
  • 1,694
  • 19
  • 26
  • You assume he wants to change every action bar in the whole app. – DKIT May 18 '15 at 13:37
  • No. By using toolbar implementation you can customise action bar for every activity. Just by setting setSupportActionBar(toolbar). Or you can define multiple action bar styles and use it according to your need. – Oguz Ozcan May 18 '15 at 17:19
  • If you have any question about this subject i can give additional information. Please remove your down vote. – Oguz Ozcan May 18 '15 at 17:39
  • was struggling for 3 hours, tried lot of things, but not working on older versions. And going to Dark from Light was the key, thanks so so much – Shirish Herwade Nov 26 '15 at 10:12
  • You welcome..By the way, I updated the answer. You can try out that too. – Oguz Ozcan Nov 26 '15 at 11:27
0

the actionbar's up arrow is an image. you can change it by download a new one and replace it:

  1. download new image,best is to download it from google material design icon page.download it in black or white in png format.save it somewhere you can find it easily.a good choice for download is the "navigate_before" icon .

  2. insert the image to the studio: file->new->image asset. rename the image to your preffered name ( ic_back for example).

  3. connect the up arrow button to the new image: inside the values/styles.xml file add the item tag like that:

     <style name="Theme.MyTheme" parent="android:Theme.Holo">   
     <item name="android:homeAsUpIndicator">@mipmap/ic_navigate_before</item>
     </style>
    

    I put the image asset inside the mipmap folder so I wrote "@mipmap" plus "/" and then the image name (mine was ic_navigate_before). hope it helped!

Gilad Levinson
  • 234
  • 2
  • 12