I am using svgandroid
to generate PictureDrawable
s from SVG raw resources. However, I can't seem to be able to apply a color filter on a drawable created this way.
The old code using PNGs
icon = getResources().getDrawable(R.drawable.ic_braille);
icon.setColorFilter(0x88880000, Mode.MULTIPLY);
((ImageView)v.findViewById(R.id.icon)).setImageDrawable(icon);
works, but
icon = SVGParser.getSVGFromResource(getResources(), R.raw.ic_braille).createPictureDrawable();
icon.setColorFilter(0x88880000, Mode.MULTIPLY);
((ImageView)v.findViewById(R.id.icon)).setImageDrawable(icon);
does not. I have tried applying the color filter on the Drawable, on the ImageView (after setting the drawable to it), through XML, even on the Drawable after setting it as the drawable of the ImageView, either is OK for the PNG but neither works for the PictureDrawable. Replacing setImageDrawable
by setBackgroundDrawable
, as suggested by some, does not render the drawable at all. I am running the code on Androids 1.6, 2.3, 4.0, no difference. I have checked the source of the SVG library, it does not touch color filters in any point. What am I doing wrong? Is tinting unavailable for some kinds of drawables?
Use this fork of svg-android: https://github.com/japgolly/svg-android
It supports ColorFilters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With