205

I've updated my SDK to API 21 and now the back/up icon is a black arrow pointing to the left.

Black back arrow

I would like it to be grey. How can I do that?

In the Play Store, for example, the arrow is white.

I've done this to set some styles. I have used @drawable/abc_ic_ab_back_mtrl_am_alpha for homeAsUpIndicator. That drawable is transparent (only alpha) but the arrow is displayed in black. I wonder if I can set the color like I do in the DrawerArrowStyle. Or if the only solution is to create my @drawable/grey_arrow and use it for homeAsUpIndicator.

<!-- Base application theme -->
<style name="AppTheme" parent="Theme.AppCompat.Light">

    <item name="android:actionBarStyle" tools:ignore="NewApi">@style/MyActionBar</item>
    <item name="actionBarStyle">@style/MyActionBar</item>

    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>

    <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
    <item name="android:homeAsUpIndicator" tools:ignore="NewApi">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>
</style>

<!-- ActionBar style -->
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">

    <item name="android:background">@color/actionbar_background</item>
    <!-- Support library compatibility -->
    <item name="background">@color/actionbar_background</item>
</style>

<!-- Style for the navigation drawer icon -->
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/actionbar_text</item>
</style>

My solution so far has been to take the @drawable/abc_ic_ab_back_mtrl_am_alpha, which seems to be white, and paint it in the color I desire using a photo editor. It works, although I would prefer to use @color/actionbar_text like in DrawerArrowStyle.

Vivek Barai
  • 1,060
  • 10
  • 25
Ferran Maylinch
  • 9,556
  • 13
  • 70
  • 89
  • None of the XML-based answers so far have solved this issue for me, but I have successfully used your `homeAsUpIndicator` / `@drawable/abc_ic_ab_back_mtrl_am_alpha` code to make the back arrow white. I prefer this than hacking into the Java. – ban-geoengineering Jan 05 '16 at 14:08
  • Old but still. Are (were) you using ActionBar or the new Toolbar? – f470071 Mar 30 '17 at 17:36
  • The default one is supposed to be a bit gray, by using android:theme="@style/Widget.AppCompat.Light.ActionBar" inside the Toolbar XML tag. Its color is #737373 – android developer Dec 18 '17 at 14:44
  • Check my answer - it is super simple and has no side-effects. – Sakiboy Feb 17 '21 at 03:09

23 Answers23

367

You can achieve it through code. Obtain the back arrow drawable, modify its color with a filter, and set it as back button.

final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(R.color.grey), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);

Revision 1:

Starting from API 23 (Marshmallow) the drawable resource abc_ic_ab_back_mtrl_am_alpha is changed to abc_ic_ab_back_material.

EDIT:

You can use this code to achieve the results you want:

toolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.blue_gray_15), PorterDuff.Mode.SRC_ATOP);
Simon
  • 18,312
  • 22
  • 130
  • 197
Carles
  • 4,329
  • 1
  • 11
  • 8
  • 4
    This is the only thing that worked for me without changing the tint off all other widgets with colorControlNormal – Joris Feb 13 '15 at 16:32
  • Works like a charm! :) – luthier Feb 22 '15 at 11:06
  • 4
    problem with this solution is it paints all your other back arrows, if you only want to change one and leave the rest white – dabluck Mar 11 '15 at 22:02
  • 1
    What about the colour of the overflow dots? – SD826E Apr 30 '15 at 22:29
  • cant find `R.color.grey` what is the color? – Sergey Shustikov May 26 '15 at 10:44
  • SRC_ATOP helped me there ! Thanks – pdegand59 May 27 '15 at 13:40
  • 1
    @ssh you have to define the a string attribute in your colors.xml file(in res/values) with the name as grey as follows `#808080` – sk1pro99 Jul 22 '15 at 06:37
  • @Carles, it coloured the back arrow white alright. But now it doesn't function properly! It doesn't go back to the previous activity! – Sid Jul 22 '15 at 09:17
  • 26
    It works. Please note you should use `ContextCompat.getDrawable(this, R.drawable.abc_ic_ab_back_mtrl_am_alpha)` because `getResources.getDrawable(int)` is deprecated – mrroboaat Aug 10 '15 at 09:24
  • 2
    It's better to change the color of arrow rather than using images. The attribute `colorControlNormal` decides the color of arrow. So change this attribute in your toolbar custom theme and enjoy :) – Neo Oct 09 '15 at 08:37
  • for problem where it changes all back arrow color in application you can use mutate().. upArrow.mutate().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP); – Pavan Nov 17 '15 at 16:18
  • 4
    Another possible solution would be for you to get that resource yourself and put it on your drawable folders :) – Mauker Dec 18 '15 at 14:53
  • how do i also customize the selector of the background of the up-button ? – android developer Jan 03 '16 at 08:58
  • 1
    ContextCompat.getColor() should also be used instead of getResources().getColor() – jdonmoyer Feb 26 '16 at 15:37
  • 12
    Note that abc_ic_ab_back_mtrl_am_alpha changed to abc_ic_ab_back_material in the 23.2.0 support library – Jon Mar 01 '16 at 10:38
  • 1
    In my case, the drawable resource is private and I can't use it, so I solved it using this another solution that worked for me (using styles only): http://stackoverflow.com/a/28631979/2969811 – YawaraNes Jun 08 '16 at 10:41
  • 3
    Note that, if you are using toolbar with theme ".NoActionBar", then getSupportActionBar().setHomeAsUpIndicator(upArrow); won't work. Use toolbar.setNavigationIcon(upArrow); then – Khaled Saif Aug 02 '16 at 05:31
  • this will not work when you upgrade support design version – Pavan Jun 29 '17 at 10:21
  • Though this solution works, Lint will show a warning, so I applied a solution with `getNavigationIcon()` here. – CoolMind Dec 25 '17 at 10:24
  • 1
    Future readers, make sure you do `supportActionBar?.setDisplayHomeAsUpEnabled(true)` before doing `toolbar?.navigationIcon?.setColorFilter(ContextCompat.getColor(this,android.R.color.white), PorterDuff.Mode.SRC_ATOP)` – daka Dec 03 '18 at 16:58
212

Looking at the Toolbar and TintManager source, drawable/abc_ic_ab_back_mtrl_am_alpha is tinted with the value of the style attribute colorControlNormal.

I did try setting this in my project (with <item name="colorControlNormal">@color/my_awesome_color</item> in my theme), but it's still black for me.

Update:

Found it. You need to set the actionBarTheme attribute (not actionBarStyle) with colorControlNormal.

Eg:

<style name="MyTheme" parent="Theme.AppCompat.Light">        
    <item name="actionBarTheme">@style/MyApp.ActionBarTheme</item>
    <item name="actionBarStyle">@style/MyApp.ActionBar</item>
    <!-- color for widget theming, eg EditText. Doesn't effect ActionBar. -->
    <item name="colorControlNormal">@color/my_awesome_color</item>
    <!-- The animated arrow style -->
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="MyApp.ActionBarTheme" parent="@style/ThemeOverlay.AppCompat.ActionBar">       
    <!-- THIS is where you can color the arrow! -->
    <item name="colorControlNormal">@color/my_awesome_color</item>
</style>

<style name="MyApp.ActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="elevation">0dp</item>      
    <!-- style for actionBar title -->  
    <item name="titleTextStyle">@style/ActionBarTitleText</item>
    <!-- style for actionBar subtitle -->  
    <item name="subtitleTextStyle">@style/ActionBarSubtitleText</item>

    <!-- 
    the actionBarTheme doesn't use the colorControlNormal attribute
    <item name="colorControlNormal">@color/my_awesome_color</item>
     -->
</style>
rockgecko
  • 3,906
  • 2
  • 15
  • 26
  • 4
    This should be the accepted answer. Thank you for this. Question, I'm unable to find the style for coloring the arrow shown when SearchView is expanded. Any clue? It apparently isn't affected by this answer. – Daniel Ochoa Jan 22 '15 at 18:25
  • 6
    I need to add also ... with the android: prefix – Seraphim's Feb 12 '15 at 20:20
  • 7
    Unfortunately this is a level 21 API and if you want to support anything below it won't work. – gphilip Mar 06 '15 at 11:35
  • 1
    Worked, but with a tweak. Instead of using `colorControlNormal` as rockgecko suggested I threw it inside ` – kellogs Jan 14 '16 at 22:42
  • 12
    If your parent theme derives from one of the "NoActionBar" themes, then setting `colorControlNormal` on the root theme rather than in the `actionBarTheme` is the route to go. – Jason Robinson Feb 01 '16 at 12:30
  • 3
    It only took me 2 hours of searching and failing and searching again to finally get to this. Sometimes the style 'system' in android drives me nuts! This method is especially important to use when you have one activity that doesn't use the same styling as the others. – Bron Davies Jun 30 '16 at 22:59
  • Expected answer Thank you – Hiren Jul 27 '16 at 08:31
  • Is this relevant to old ActionBar or new Toolbar? – f470071 Mar 30 '17 at 18:19
  • @JasonRobinson Your comment worked for me, thanks +1. This answer however, did not, not sure why. – daka Dec 02 '18 at 19:17
  • Great answer! I saved me the whole life. – Johnny Jul 05 '19 at 04:38
127

Tried all suggestions above. The only way that I managed to change the color of navigation icon default Back button arrow in my toolbar is to set colorControlNormal in base theme like this. Probably due to the fact that the parent is using Theme.AppCompat.Light.NoActionBar

<style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
  <item name="colorControlNormal">@color/white</item> 
  //the rest of your codes...
</style>
Harry Aung
  • 1,572
  • 1
  • 12
  • 6
  • 6
    Simplest answer of all, instead of fiddling around with other code, just add this line in your `style.xml` – Rohan Kandwal Nov 12 '15 at 14:04
  • 3
    remember that colorControlNormal requires API 21 – Adnan Ali Jun 01 '16 at 18:40
  • 3
    @AdnanAli if you're using AppCompat it'll work on < API 21 as well. Clearly, AppCompat _is_ being used here because `colorControlNormal` is _not_ prefixed with `android:`. – Vicky Chijwani Jun 11 '16 at 15:14
  • 5
    But this changes the tint off all other widgets as well.. any way not to affect other widgets such as checkbox and radio buttons? – Bruce Sep 12 '16 at 08:22
  • 3
    But this also changes the colour of other controls, like radio buttons and the line under text edit. – daka Dec 03 '18 at 16:47
  • Changing theme to Xxx.NoActionBar causes NPE on "getSupportActionBar". – Henry Dec 06 '18 at 08:21
  • @Henry NoActionBar theme won't provide default action bar. So you need to setup your own toolbar by like so `setSupportActionBar(toolbar)` where toolbar is the one you setup in xml. – Harry Aung Dec 12 '18 at 04:03
  • Excellent! Best solution. – John T Mar 19 '19 at 02:35
69

Need to add a single attribute to your toolbar theme -

<style name="toolbar_theme" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="colorControlNormal">@color/arrow_color</item>
</style>

Apply this toolbar_theme to your toolbar.

OR

you can directly apply to your theme -

<style name="CustomTheme" parent="Theme.AppCompat.Light.NoActionBar">
  <item name="colorControlNormal">@color/arrow_color</item> 
  //your code ....
</style>
Neo
  • 3,402
  • 1
  • 23
  • 29
  • 5
    Trying the accepted answer (maybe the most popular solution found on the net) does not work for me but ***this one works*** :) so crazy when programming with Android. – King King Sep 15 '16 at 09:33
  • 5
    Simplest answer. This works without changing other control themes. All you need is to set the custom toolbar theme to your toolbar. :) – SimplyProgrammer Nov 24 '16 at 07:45
  • 1
    Oh the pains you have to go through to change the color of just 1 icon.. The first one works for me. The 2nd one works for custom Toolbars (and other things too apparently). 3 years later, many thanks Neo. – Aba May 15 '18 at 08:16
46

Just add

<item name="colorControlNormal">@color/white</item> 

to your current app theme.

S bruce
  • 1,454
  • 3
  • 14
  • 23
36

if use Toolbar,you can try this

Drawable drawable = toolbar.getNavigationIcon();
drawable.setColorFilter(ContextCompat.getColor(appCompatActivity, colorId), PorterDuff.Mode.SRC_ATOP);
longbaobao
  • 369
  • 3
  • 4
  • This should be the accepted answer, imho - it targets just the arrow, gets the arrow to set using simplest means, and is compatible also below API 21 – Antek Jun 08 '17 at 15:36
  • If you seek more custom solution (different colors for titles and menu icons in my case) then this is the solution you want – TheJudge Aug 29 '17 at 10:25
  • 3
    Note that you might need to call this before attempting to call getNavigationIcon(): getSupportActionBar().setDisplayHomeAsUpEnabled(true); – rrbrambley Nov 14 '17 at 19:02
  • The best answer! Thank you. – shariful islam Mar 07 '19 at 09:26
32

As said on most of the previous comments, the solution is to add

<item name="colorControlNormal">@color/white</item> to your app theme. But confirm that you don´t have another theme defined in your Toolbar element on your layout.

     <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:elevation="4dp"
            android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
manuelvsc
  • 495
  • 7
  • 11
  • 3
    Brilliant... I tried all the about answers to add it in the theme but it did not work... As you mentioned, I had android:theme="@style/ThemeOverlay.AppCompat.ActionBar" property in my tool bar. Once I removed it, it started working. – Rahul Hawge Sep 27 '16 at 06:49
10

The answer by Carles is the correct answer, but few of the methods like getDrawable(), getColor() got deprecated at the time I am writing this answer. So the updated answer would be

Drawable upArrow = ContextCompat.getDrawable(context, R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(ContextCompat.getColor(context, R.color.white), PorterDuff.Mode.SRC_ATOP);
getSupportActionBar().setHomeAsUpIndicator(upArrow);

Following some other stackoverflow queries I found that calling ContextCompat.getDrawable() is similar to

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    return resources.getDrawable(id, context.getTheme());
} else {
    return resources.getDrawable(id);
}

And ContextCompat.getColor() is similar to

public static final int getColor(Context context, int id) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 23) {
        return ContextCompatApi23.getColor(context, id);
    } else {
        return context.getResources().getColor(id);
    }
}

Link 1: ContextCompat.getDrawable()

Link 2: ContextCompat.getColor()

Community
  • 1
  • 1
capt.swag
  • 8,997
  • 1
  • 33
  • 35
7

I found a solution that works pre Lollipop. Set the "colorControlNormal" within the "actionBarWidgetTheme" to change the homeAsUpIndicator color. Modifying rockgecko's answer from above to look like this:

<style name="MyTheme" parent="Theme.AppCompat.Light">        
    <item name="actionBarTheme">@style/MyApp.ActionBarTheme</item>
    <item name="actionBarStyle">@style/MyApp.ActionBar</item>
    <!-- color for widget theming, eg EditText. Doesn't effect ActionBar. -->
    <item name="colorControlNormal">@color/my_awesome_color</item>
    <!-- The animated arrow style -->
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <!-- The style for the widgets on the ActionBar. -->
    <item name="actionBarWidgetTheme">@style/WidgetStyle</item>
</style>

<style name="WidgetStyle" parent="style/ThemeOverlay.AppCompat.Light">
    <item name="colorControlNormal">@color/my_awesome_color</item>
</style>
GFred
  • 133
  • 2
  • 7
7

On compileSdkVersoin 25, you could do this:

styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">
     <item name="android:textColorSecondary">@color/your_color</item>
</style>
chrizonline
  • 3,969
  • 15
  • 53
  • 91
7

enter image description here

Change Menu Nav Icon Color

Final convert Menu Icon Color

In style.xml :

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:textColor">@color/colorAccent</item>


</style>

<style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/colorPrimaryDark</item>
</style>







In Mainfests.xml :

<activity android:name=".MainActivity"
        android:theme="@style/MyMaterialTheme.Base"></activity>
Sumit Saxena
  • 309
  • 3
  • 8
6

Use below method:

private Drawable getColoredArrow() {
    Drawable arrowDrawable = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    Drawable wrapped = DrawableCompat.wrap(arrowDrawable);

    if (arrowDrawable != null && wrapped != null) {
        // This should avoid tinting all the arrows
        arrowDrawable.mutate();
        DrawableCompat.setTint(wrapped, Color.GRAY);
    }

    return wrapped;
}

Now you can set the drawable with:

getSupportActionBar().setHomeAsUpIndicator(getColoredArrow());
kirtan403
  • 6,539
  • 5
  • 43
  • 87
Jumpa
  • 3,731
  • 9
  • 41
  • 86
5

Another solution that might work for you is to not declare your toolbar as the app's action bar ( by setActionBar or setSupportActionBar ) and set the back icon in your onActivityCreated using the code mentioned in another answer on this page

final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
upArrow.setColorFilter(getResources().getColor(R.color.grey), PorterDuff.Mode.SRC_ATOP);
toolbar.setNavigationIcon(upArrow);

Now, you will not get the onOptionItemSelected callback when you press the back button. However, you can register for that using setNavigationOnClickListener. This is what i do:

toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        getActivity().onBackPressed(); //or whatever you used to do on your onOptionItemSelected's android.R.id.home callback
    }
});

I'm not sure if it will work if you work with menu items.

Jared Rummler
  • 35,743
  • 18
  • 127
  • 142
Vinay W
  • 9,323
  • 7
  • 35
  • 44
3

We were running into the same problem and all we wanted was to set the

app:collapseIcon

attribute in the toolbar in the end, which we did not find since it is not very well documented :)

<android.support.v7.widget.Toolbar
         android:id="@+id/toolbar"
         android:layout_width="match_parent"
         android:layout_height="@dimen/toolbarHeight"
         app:collapseIcon="@drawable/collapseBackIcon" />
Community
  • 1
  • 1
Julian Horst
  • 716
  • 7
  • 14
3

try this

public void enableActionBarHomeButton(AppCompatActivity appCompatActivity, int colorId){

    final Drawable upArrow = ContextCompat.getDrawable(appCompatActivity, R.drawable.abc_ic_ab_back_material);
    upArrow.setColorFilter(ContextCompat.getColor(appCompatActivity, colorId), PorterDuff.Mode.SRC_ATOP);

    android.support.v7.app.ActionBar mActionBar = appCompatActivity.getSupportActionBar();
    mActionBar.setHomeAsUpIndicator(upArrow);
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayHomeAsUpEnabled(true);
}

function call:

enableActionBarHomeButton(this, R.color.white);
Siddarth Kanted
  • 5,182
  • 1
  • 26
  • 19
3

I just changed the toolbar theme to be @style/ThemeOverlay.AppCompat.Light

and the arrow became dark gray

            <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:gravity="center"
            app:layout_collapseMode="pin"
            app:theme="@style/ThemeOverlay.AppCompat.Light">
fullmoon
  • 6,463
  • 3
  • 34
  • 52
3

Here's how I did it in Material Components:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="drawerArrowStyle">@style/AppTheme.DrawerArrowToggle</item>
</style>

<style name="AppTheme.DrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@android:color/white</item>
</style>
Sam
  • 35,545
  • 30
  • 157
  • 202
3

Solution is very simple

Just put following line into your style named as AppTheme

<item name="colorControlNormal">@color/white</item>

Now your whole xml code will look like shown below (default style).

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

        <item name="colorPrimary">#0F0F0F</item>
        <item name="android:statusBarColor">#EEEEF0</item>
        <item name="android:windowLightStatusBar">true</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowActivityTransitions">true</item>

        <item name="colorControlNormal">@color/white</item>
</style>
Suyog
  • 375
  • 1
  • 3
  • 14
2

This is what worked for me:

Add the below attributes to your theme.

To change toolbar/actionbar back arrow above api 21

<item name="android:homeAsUpIndicator">@drawable/your_drawable_icon</item>

To change toolbar/actionbar back arrow below api 21

<item name="homeAsUpIndicator">@drawable/your_drawable_icon</item>

To change action mode back arrow

<item name="actionModeCloseDrawable">@drawable/your_drawable_icon</item>

To remove toolbar/actionbar shadow

<item name="android:elevation" tools:targetApi="lollipop">0dp</item>
<item name="elevation">0dp</item>
<!--backward compatibility-->
<item name="android:windowContentOverlay">@null</item>

To change actionbar overflow drawable

<!--under theme-->
<item name="actionOverflowButtonStyle">@style/MenuOverflowStyle</item>

<style name="MenuOverflowStyle" parent="Widget.AppCompat.ActionButton.Overflow">
<item name="srcCompat">@drawable/ic_menu_overflow</item>

Note : 'srcCompat' is used instead of 'android:src' because of vector drawable support for api below 21

Sadashiv
  • 773
  • 8
  • 18
0

You can change the color of the navigation icon programmatically like this:

mToolbar.setNavigationIcon(getColoredArrow()); 

private Drawable getColoredArrow() {
        Drawable arrowDrawable = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        Drawable wrapped = DrawableCompat.wrap(arrowDrawable);

        if (arrowDrawable != null && wrapped != null) {
            // This should avoid tinting all the arrows
            arrowDrawable.mutate();
                DrawableCompat.setTintList(wrapped, ColorStateList.valueOf(this.getResources().getColor(R.color.your_color)));
            }
        }

        return wrapped;
}
Pravesh
  • 752
  • 1
  • 7
  • 18
0

The simplest (and best) way to change the color of the back/up-arrow. Best part is that there are no side-effects (unlike the other answers)!

  • Create a style with parent Widget.AppCompat.DrawerArrowToggle, define the color and any other attributes you'd like.
  • Set the style on the drawerArrowStyle attribute in the apps Theme.

Create style:

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <!--        Set that the nav buttons will animate-->
    <item name="spinBars">true</item>
    <!--        Set the color of the up arrow / hamburger button-->
    <item name="color">@color/white</item>
</style>

Set the style in App Theme:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <!--  Change global up-arrow color with no side-effects    -->
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

To change the ToolBar text color (and other attributes), create this style:

<style name="ToolbarStyle" parent="Widget.AppCompat.Toolbar">
    <item name="android:textColor">@color/white</item>
    <item name="titleTextColor">@color/white</item>
    <item name="colorControlNormal">@color/white</item> <!-- colorControlNormal is Probably not necessary    -->
</style>

Then set that style on the AppTheme:

<!-- Base application theme. -->
<style name="AppTheme.MyProduceApp" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <!--  Style the toolbar (mostly the color of the text) -->
    <item name="toolbarStyle">@style/ToolbarStyle</item>
    <!--  Change color of up-arrow    -->
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
Sakiboy
  • 6,255
  • 6
  • 47
  • 63
-1

Just remove android:homeAsUpIndicator and homeAsUpIndicator from your theme and it will be fine. The color attribute in your DrawerArrowStyle style must be enough.

Flávio Faria
  • 6,370
  • 3
  • 37
  • 57
  • I already tried that and the arrow is black. Note this arrow is not the same arrow you see when you open the drawer (that arrow IS affected by the `color` attribute). The drawer arrow is a bit bigger. – Ferran Maylinch Nov 06 '14 at 22:07
  • 1
    So, it seems you'll have to provide your own drawable resource. You can generate it using this tool: http://shreyasachar.github.io/AndroidAssetStudio/ – Flávio Faria Nov 07 '14 at 18:17
-4

Unless there's a better solution...

What I did is to take the @drawable/abc_ic_ab_back_mtrl_am_alpha images, which seem to be white, and paint them in the color I desire using a photo editor.

Ferran Maylinch
  • 9,556
  • 13
  • 70
  • 89