How to disable AppCompat r22.1 app bar overflow icon?
I know I can replace the icon by setting a custom actionOverflowButtonStyle
one as described here . However, this style only allows you to set different patterns and / or backgrounds.
Instead, I would like to use the standard icon provided by AppCompat, simply tint it with a specific color, just like the icon / back drawer button can be tinted using an attribute color
in drawerArrowStyle
.
I have tried these methods reportedly used to work:
- Customization
colorControlNormal
- Toolbar Icon on Android - Setting
textColorPrimary
in Theme - MenuItem in AppCompat Toolbar - Customization
actionBarStyle
and changecolorControlNormal
there.
But as far as I can see, none of them work with the latest AppCompat - the overflow icon retains its original color (while other widgets like TextViews or the text in menu items change).
Should it be done differently? I am not using a custom view Toolbar
, just a default AppCompat supported application, similar to ActionBar.
How to reproduce:
- Create a default Android Studio project with minimum SDK version = 9.
- This automatically includes an empty action and a menu resource with a single Settings menu item using
app:showAsAction="never"
, which means it will show up in the overflow menu. -
Finally, customize the file
styles.xml
. For example:<resources> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">#008888</item> <item name="colorControlNormal">#ff0000</item> <item name="android:textColorPrimary">#ff0000</item> </style> </resources>
You will notice that no property affects the color of the overflow menu icon. Tested on Nexus 5 with Android 5.1.1.
source to share
If you trace the theme Theme.AppCompat.Light.DarkActionBar
, you can see that it installs:
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
In turn, it inherits from Base.ThemeOverlay.AppCompat.Dark
, which sets:
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
Which is essentially equal to white:
<color name="primary_text_default_material_dark">#ffffffff</color>
If you just inherit Base.Theme.AppCompat.Light
, you won't run into this issue as it doesn't install actionBarTheme
. You can easily customize the action bar using the material properties anyway.
source to share