guillaume-tgl guillaume-tgl - 1 year ago 177
Android Question

Tint menu icons

I'm building an Android app and I use the icons from the Action Bar Icon Pack to use in the action bar. I define them through the xml files in the

Is there a way to "tint" these icons so that they are all the same color?
So far, I have to do it manually with an image editing software but if I decide to change the color, I have to do it all over again.

I know there is a
attribute for
but I haven't found a way to use it for the menu's icons.


Answer Source

There may be a better way to do this, but one option is to redraw the icon in code.

Suppose you have a menu item for favorites and want to tint it gray:

MenuItem favoriteItem = menu.findItem(;
Drawable newIcon = (Drawable)favoriteItem.getIcon();
newIcon.mutate().setColorFilter(Color.argb(255, 200, 200, 200), PorterDuff.Mode.SRC_IN);

You can also use a color resource like

newIcon.mutate().setColorFilter(getResources().getColor(R.color.myCustomTint), PorterDuff.Mode.SRC_IN);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download