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());
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());
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.
No, it does not, other than via
WebView
or third-party SVG rendering libraries.You are welcome to show SVG files via
WebView
or third-party SVG rendering libraries.VectorDrawable
is an option; it is not a requirement.There is no
SVGParser
class in the Android SDK.