gnB gnB - 1 year ago 109
Android Question

Can provided Android SDK icons be set with color?

Android SDK provides the following icons.

Is there a way to set a color to those .. and if possible, how to do so?



enter image description here


After doing a complete refresh of the project, it turns out the
attribute in Xml did the trick.

For the short answer

.. this is the solution that worked for me - adding the property to the ImageView xml:


The answer from @goldenb is a thorough run through of the different ways to solve for this, so am marking that one as the answer.

Answer Source

You can indeed use a tint as a way of changing an ImageView's colour, BUT you should be reminded that the android:tint will always be applied on top of the original colour.

as stated by blogger danlew

  • ImageView's tint mixes the tint color with the original asset. What you want is for the tint color to take over entirely; instead it applies the tint on top of the existing color. So, for example, if the source asset is black, and you want it to be #77FFFFFF (a translucent shade of white), you'll actually end up getting that shade of white with a black background beneath it.

  • android:tint is limited to ImageView. You want to be able to tint any Drawable in any View.

One possible alternative would be for you to use android ColorFilter

According to the official documentation:

A color filter can be used with a Paint to modify the color of each pixel drawn with that paint. This is an abstract class that should never be used directly.

There are lots of more or less complex things you can do with ColorFilter but how can you apply this then?

One simple example from another so question is:

//White tint
imageView.setColorFilter(Color.argb(255, 255, 255, 255)); 



Or a more complete answer here in SO from here

ImageView redCircle = (ImageView) findViewById(;
ImageView greenCircle = (ImageView) findViewById(;
ImageView blueCircle = (ImageView) findViewById(;

// we can create the color values in different ways:
redCircle.getDrawable().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY );
greenCircle.getDrawable().setColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY );
blueCircle.getDrawable().setColorFilter(getResources().getColor(, PorterDuff.Mode.MULTIPLY );

You should check these links if you want to learn more

SO - What is the difference between background, backgroundTint, backgroundTintMode attributes in android layout xml?


Fast Android asset theming with ColorFilter

SO-Modifying the color of an android drawable

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download