Siri
Siri

Reputation: 701

How to change ActionBar overflow icon

Below is my style:

 <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <!-- <item name="windowActionBar">false</item> -->
    </style>

    <style name="AppTheme" parent="AppBaseTheme">
        <item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
        <!-- <item name="actionBarStyle">@style/Theme.MyApp.ActionBar</item> -->
    </style>
 <style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow">

        <!-- Required for pre-Lollipop. -->
        <item name="overlapAnchor">false</item>

        <!-- Required for Lollipop. -->
        <!-- <item name="android:overlapAnchor">false</item> -->
    </style>

I'm using ActionBarActivity from the appcompact support library to change the overflowbutton color.

  <style name="AppTheme" parent="AppBaseTheme">
        <item name="actionOverflowMenuStyle">@style/OverflowMenu</item>
        <item name="android:actionOverflowButtonStyle">@style/OverFlowStyle</item>

        <!-- <item name="actionBarStyle">@style/Theme.MyApp.ActionBar</item> -->
    </style>

    <style name="OverFlowStyle" parent="Widget.AppCompat.ActionButton.Overflow">
        <item name="android:src">@drawable/ic_empty</item>
    </style>

Upvotes: 2

Views: 2279

Answers (4)

Atul O Holic
Atul O Holic

Reputation: 6792

With toolbar, none of the above worked for me and I had to change it via code, using the below:

public static void setOverflowButtonColor(final Activity activity) {
    final String overflowDescription = activity.getString(R.string.abc_action_menu_overflow_description);
    final ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    final ViewTreeObserver viewTreeObserver = decorView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            final ArrayList<View> outViews = new ArrayList<View>();
            decorView.findViewsWithText(outViews, overflowDescription,
                    View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
            if (outViews.isEmpty()) {
                return;
            }
            TintImageView overflow=(TintImageView) outViews.get(0);
            overflow.setColorFilter(Color.CYAN);
            removeOnGlobalLayoutListener(decorView,this);
        }
    });
}

Complete source.

Upvotes: 1

KSP
KSP

Reputation: 83

    <style name="OverFlowStyle" parent="@style/Widget.AppCompat.Light.ActionButton.Overflow">
            <item name="android:src">@drawable/green_overflow</item>
        </style>
    <style name="AppTheme" parent="AppBaseTheme">
    <item name="actionOverflowButtonStyle">@style/OverFlowStyle</item>
            <item name="android:actionOverflowButtonStyle">@style/OverFlowStyle</item>
</style>

Upvotes: 3

Pooja
Pooja

Reputation: 2467

For android version < 21 it should be like this.

<style name="AppTheme" parent="AppBaseTheme">

         ...
     <item name="actionOverflowButtonStyle">@style/OverFlowStyle</item>
</style>

<style name="OverFlowStyle" parent="Widget.AppCompat.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_empty</item>
</style>

Upvotes: 1

Simas
Simas

Reputation: 44178

As a comment in your styles implies, android: prefix is required for lollipop. Have you tried adding it to the actionOverflowMenuStyle attribute too?

<item name="android:actionOverflowButtonStyle">@style/OverflowMenu</item>
<item name="actionOverflowButtonStyle">@style/OverflowMenu</item>

Upvotes: 1

Related Questions