Search code examples
androidvector-graphics

Menu item icon changes color


I've created a menu with a single item.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/syncButton"
        android:title="Sync"
        android:icon="@drawable/ic_sub_menu"
        app:showAsAction="never"/>
</menu>

This is used on some of my activities in the toolbar, when clicked it drops down a menu, currently there is only one option but in the future it may be more.

Everything works well except the icon, it's a vector image of the traditional 3 dots colored white. Depending on what showAsAction" is set as it changes color.

Currently showAsAction is set to never so it displays a menu when clicked, this is what I want, but the icon changes to a dark grey. If i set this option to "always" then the icon changes to white but I lose the drop down menu.

How can I keep the drop down menu while keeping my icon white ?


Solution

  • If you just want to change the 3-Dots-Icon for the DropDownMenu, you can change this in your Styles.xml:

    In your Theme Style define

    <item name="android:actionOverflowButtonStyle">@style/MyTheme.OverFlow</item>
    

    and then define the Overflow with your Icon you want to show instead the 3DotsIcon (in your case the Icon with 3 white dots)

      <style name="MyTheme.OverFlow">
        <item name="android:src">@drawable/yourNewIcon</item>
      </style>