UzUmAkI_NaRuTo
UzUmAkI_NaRuTo

Reputation: 575

Overflow menu icon color won't change for android < 21

I am trying to change overflow menu icon color of the toolbar, which is like this :-

<android.support.v7.widget.Toolbar 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/toolbar_actionbar"
  android:layout_width="match_parent"
  android:layout_height="?attr/actionBarSize"
  app:layout_scrollFlags="scroll|enterAlways"
  app:popupTheme="@style/CustomPopup"
  app:theme="@style/MyCustomToolBarTheme">    
</android.support.v7.widget.Toolbar>

The two custom themes :-

<style name="MyCustomToolBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
        <item name="android:textColorSecondary">@android:color/white</item>
</style>
<style name="CustomPopup" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:textColorSecondary">@android:color/white</item>
</style>

I can change title/menu icon color too. But the overflow icon color is always black.I even tried specifying custom icon that too didn't work.

Upvotes: 0

Views: 719

Answers (3)

ekeitho
ekeitho

Reputation: 121

Change your parent from "ThemeOverlay.AppCompat.Light" to "Theme.AppCompat.Light".

<style name="ToolbarOverflow" parent="Theme.AppCompat.Light">
    <item name="android:textColorSecondary">@color/white</item>
</style>

Upvotes: 0

Alan Haden
Alan Haden

Reputation: 147

I resolved the issue by replacing the overflow icon with one of my own and setting its colour myself.

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="actionOverflowButtonStyle">@style/OverflowMenuButton</item>
</style>


<style name="OverflowMenuButton" parent="Theme.AppCompat.NoActionBar" >
    <item name="android:src">@drawable/overflow</item>
</style>

Upvotes: 0

Gerard Frijters
Gerard Frijters

Reputation: 358

You may try the next:

    public static void setOverflowButtonColor(final Toolbar toolbar, final int color) {
    Drawable drawable = toolbar.getOverflowIcon();
    if(drawable != null) {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable.mutate(), color);
        toolbar.setOverflowIcon(drawable);
    }
}

Upvotes: 0

Related Questions