How do I change the color of actionbar's up arrow?

前端 未结 3 877
攒了一身酷
攒了一身酷 2020-12-15 06: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

相关标签:
3条回答
  • 2020-12-15 06:37

    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.

    0 讨论(0)
  • 2020-12-15 06:43

    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>
    
    0 讨论(0)
  • 2020-12-15 06:56

    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!

    0 讨论(0)
提交回复
热议问题