1

I am working on drawable icons for app icons.I apply different color on icon dynamically which apply successfully on icons.but when i apply blue color either its dark blue or light blue, It does not appear on icon. can anybody tell the reason please. I am using this code to apply color.

 colorCode = sp.getString("initialColor", "#ffffff");
        icon.setBounds(0, 0, sIconWidth, sIconHeight);
        int color = Color.parseColor(colorCode);
        int i = Color.argb(0,
                color, color, color);
        icon.mutate().setColorFilter(i, PorterDuff.Mode.MULTIPLY );
Junaid
  • 316
  • 5
  • 23

1 Answers1

1

What is your error? That's not the right way to set an background color of your icon.

You should do:

        android:background="@color/nameOfYourColor"
        android:src="@drawable/your_image_button"

If you wanna make a shape, you sould declare the shape at Drawable folder and set the background as the shape name.

  • actually i am trying to put a color layer on the top of image. not in of bacground image – Junaid Apr 22 '16 at 13:36
  • So you should do the same thing. But instead that, you will create an ImageView with your background color. And create an Drawable xml object. with the first parameter your image and the second the color what you wanna and the shape. Or you should try this code over here: http://stackoverflow.com/questions/11312680/how-to-set-combined-color-for-overlapped-area-of-two-different-color-objects yellowCircle.getDrawable().setColorFilter(0x88ffff00,PorterDuff.Mode.MULTIPLY); – Luciano Moura Apr 22 '16 at 13:41