I tried to load PNG image form drawable into ImageView, and set tint color for this ImageView with below code ⇒ it's working:
imageView1.setImageResource(R.drawable.pngFile);
imageView1.setColorFilter(getResources().getColor(R.color.colorAccent), android.graphics.PorterDuff.Mode.MULTIPLY);
I want to load SVG image into ImageView using Glide and set tint color for it. But after successfully loading SVG image into imageView, setColorFilter NOT WORKING.
I could load SVG image into another ImageView using Glide with the below code:
// Setup RequestBuilder
requestBuilder = Glide.with(mActivity)
.using(Glide.buildStreamModelLoader(Uri.class, mActivity),
InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder()))
.decoder(new SvgDecoder())
.placeholder(R.drawable.ic_facebook)
.error(R.drawable.ic_web)
.animate(android.R.anim.fade_in)
.listener(new SvgSoftwareLayerSetter<Uri>());
// Use RequestBuilder with uri
Uri uri = Uri.parse("http://upload.wikimedia.org/wikipedia/commons/e/e8/Svg_example3.svg");
requestBuilder
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.load(uri)
.into(imageView2);
Now, I want to change tint color of mageView2 (after successfully loading SVG image into imageView2), I tried the below code but it's not working:
imageView2.setColorFilter(getResources().getColor(R.color.colorAccent), android.graphics.PorterDuff.Mode.MULTIPLY);