How to change color of the back arrow in the new Material theme?
Fast track to changing the back arrow color in the Material Theme? Set the android:tint
in your toolbar's style. Here's a quick setup:
Then apply this style to your Toolbar
:
Replace @color/custom_back_arrow_color
with your specific color resource.
Delving deeper: code customization
Let's get our coding gloves on and delve deeper into all the possible ways to customize the back arrow color.
Changing color via theme attributes
Artists tweak the finest details. We tweak the colorControlNormal
within your app theme to make sure all navigation elements have a similar color scheme:
Changing color in Java/Kotlin
For those who prefer more dynamic color changes during runtime, apply a fresh coat of color with a few lines of Java or Kotlin:
Considering API levels
If you're working with API 23 and above, invite abc_ic_ab_back_material
to be your drawable resource. Et voilà! your back arrow is theme-ready.
Advanced color-changing methods
Ready to take the "wheel"? Let's drive through the more advanced scenarios of changing back arrow colors.
Custom drawables
If you're looking to add custom drawables for different versions in your resources, here's how to do it:
Color changes using DrawerArrowStyle
Keep the back arrow color in line with your app's theme using DrawerArrowStyle
. You can define the color resource once and let your whole app benefit from the change:
Enhancing navigation with navigation icon
Why stop at the back arrow when you have the whole navigation icon to experiment with:
Was this article helpful?