Quick guide: How to load remote .svg file in Android

Mladen Rakonjac
Fleka Developers
Published in
2 min readNov 25, 2016

--

First of all, I recommend you to read this story . It compares PROs and CONs of png VS svg.

If you are in Android development, you know that .svg files are not supported. We, at fleka, are trying to use .svg file as much as we can. There are a lot of benefits. It is scaleable and it saves our designers’ time. No need for extra export! There is a workaround called Vector Drawable , android xml vector file, but it is only local solution. What if icon is in remote data source ? For example we have the files on our S3 bucket. How to download that icon for given url and show it in ImageView?

Thanks to AndroidSvg and Glide ( not golang one :D ) , there is a solution.

I dig into Glide’s github repository and I have found really nice sample.

First, you have to download androidSvg .jar file from this link. Next, you have to add .jar file in app/libs/ path. You will find that path if you select Project files in the dropdown at the top of the Project window. If there is no libs folder, make one. Right click on app folder -> new -> Directory . Name it libs. Once when you add .jar file, you have to include it as a library. To do that, you have to right click on .jar file and click on Add As Library…

Next, you have to sync project with Gradle files.

You have added AndroidSvg. So far so good!

To enable Glide to load .svg from web, you have to add following three classes to project: class1, class2, class3 . And magic is here:

--

--