Search code examples
androidoverflow-menu

Change the overflow icon to a new image


I have an issue with the overflow menu. I need to replace the 3 dots with my image. I tried out several ways but its not working.

In my styles.xml, I have added the following code:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    ...
    <item name="actionOverflowButtonStyle">@style/MyOverFlowMenu</item>
    <item name="android:actionOverflowButtonStyle">@style/MyOverFlowMenu</item>
</style>

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

My application works from Android 4.4 onwards to the latest. Could some one let me know whats wrong behind this code? Thanks in advance.


Solution

  • It worked when I did programatically. Here goes the code for the same:

    Drawable drawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.my_overflow);
    toolbar.setOverflowIcon(drawable);