Skip to content
Advertisement

Image becomes blurry when loading SVG with Glide

In the app I’m using the following sample to load an SVG image into ImageView:

JavaScript

An ImageView in xml looks like this:

JavaScript

So, the problem can be seen on the image below. The right icon was set from app’s resources, while the left one is loaded from server using Glide. For some reason image is not scaling properly and looks blurry.

images to compare

I’ve already tried the solution from this answer: Image size too small when loading SVG with Glide, but it doesn’t work.

Advertisement

Answer

After upgrading to glide v4 the problem has gone. Now I’m using the following code for loading svg:

JavaScript

And in my AppGlideModule I have:

JavaScript

SvgDrawableTranscoder converts SVG to PictureDrawable with one simple method:

JavaScript

And that’s how I implemented SvgEncoder class:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement