Mohammad Haidar
Mohammad Haidar

Reputation: 1135

Change the color of default back arrow provided by action bar

I am setting the back arrow of the action bar and changing its color like so:

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

And as you can see, I am changing the color of the arrow in this line because the default returned arrow is gray, here:

upArrow.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);

And the color is changing but the problem that it is a bit transparent although the color white that I am providing has the following hex code #FFFFFFFF.

Here are two images that will make my point clear.

This is how it looks:

This is how it looks

While the color should like this other component:

enter image description here

And I tried all the options that are under PorterDuff.Mode.XXXX but none worked.

Upvotes: 1

Views: 2295

Answers (2)

Damini Mehra
Damini Mehra

Reputation: 3347

plz change in your style.xml

    <style name="MyCustomTheme" parent="Custom.Base">

   </style>

<style name="Custom.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>
</style>

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

Upvotes: 2

Amol Nage
Amol Nage

Reputation: 85

If you're using Toolbar then add item in your AppTheme.

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

But Make sure that you don´t have another theme defined in your Toolbar element on your layout.

Upvotes: 1

Related Questions