Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between SVG and VectorDrawable in Android

While Android supports SVG, why should it be converted to VectorDrawable?

This code example shows SVG in Android:

SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
imageView.setImageDrawable(svg.createPictureDrawable());
like image 222
Sadegh Hoseini Avatar asked Aug 10 '15 18:08

Sadegh Hoseini


1 Answers

The SVGParser functionality you mention is a third party implementation of SVG support for Android.

The major problems with using SVG in Android are:

  • SVG files may be very complex and can be very slow to render

  • All the third party implementations I have used have had bugs and failed to load or render some SVG files correctly

  • Most of the third party implementations have been abandoned and none seem to be actively maintained

I have written more about using SVG files in Android and the available third party libraries in the following article:

https://androidbycode.wordpress.com/2015/02/27/vector-graphics-in-android-part-1-svg/

VectorDrawable supports of subset of SVG format that is designed to ensure it is fast to render. I have written about VectorDrawable and how to convert your existing SVG files to VectorDrawable here.

like image 58
BrentM Avatar answered Oct 14 '22 10:10

BrentM