Android: unable to change back arrow color

I am using the new appompap toolbar for Android. I need to set the same color for hamburger icons and back arrows. Using drawerArrowStyle allows me to change the hamburger icon, but not the arrow. The problem is only with Lollipop devices, anything, before Lellopop.

Burger

Arrow

Here is the code:

Toolbar:

<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:local="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize" android:background="@color/my_primary" local:theme="@style/My.Toolbar" local:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> 

Style.xml:

 <style name="Theme.Base" parent="Theme.AppCompat.Light"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="windowActionBar">false</item> <item name="android:windowNoTitle">true</item> <!-- colorPrimary is used for the default action bar background --> <item name="colorPrimary">@color/my_primary</item> <!-- colorPrimaryDark is used for the status bar --> <item name="colorPrimaryDark">@color/black</item> </style> <style name="My.Theme" parent="Theme.Base"> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> </style> <style name="My.Toolbar" parent="Theme.AppCompat.NoActionBar"> <!-- color of the title text in the Toolbar, in the Theme.AppCompat theme: --> <item name="android:textColorPrimary">@color/my_actionbartext</item> <!-- necessary to support older Android versions.--> <item name="actionMenuTextColor">@color/my_actionbartext</item> <item name="android:textColorSecondary">@color/my_actionbartext</item> </style> <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> <item name="color">@color/my_actionbartext</item> </style> 

I tried to use the solution from here , but it did not work. Does anyone have any ideas?

+5
source share
4 answers

Just do it in your activity / snippet:

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha, null)); else getSupportActionBar().setHomeAsUpIndicator(getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha)); getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
+2
source

The way to the correct solution to the problem was found here.

However, this still did not work 100% due to our use of DrawerLayout. My colleague wrote a great post by decision here

+1
source

I also cannot update the back arrow button after upgrading to support library 23.2.0.

 <style name="ThemeOverlay.MyApp.ActionBar" parent="ThemeOverlay.AppCompat.ActionBar"> <item name="android:textColorPrimary">@color/white</item> <item name="android:textColorSecondary">@color/white</item> </style> 
+1
source

This is the color of actionMenuTextColor. Add this line to your topic.

 <item name="actionMenuTextColor">your color</item> 
0
source

Source: https://habr.com/ru/post/1214116/


All Articles