Automatically exported from code.google.com/p/androidsvg
AndroidSVG is a SVG parser and renderer for Android. It has almost complete support for the static visual elements of the SVG 1.1 and SVG 1.2 Tiny specifications (except for filters). AndroidSVG correctly renders the SVG Acid Test.
AndroidSVG is licensed under the Apache License v2.0.
The current release (v1.2.1) is hosted at Bitbucket.
Check the Release Notes to find out what's in the latest release.
Older releases can be found on this site's downloads page.
A design goal of this project is to correctly render SVG files that have been exported from the most popular vector editors. AndroidSVG has been tested with files generated by Adobe Illustrator, Inkscape, Xara and Corel Draw.
Download the latest release from the download page and add it to your project. If you are using Eclipse, you can drag the library to the libs folder for your project in the Package Explorer.
For those building with Maven, AndroidSVG releases are also avaliable in the Maven Central Repository. To include AndroidSVG in your project, add the following dependency to your POM file.
<dependency> <groupId>com.caverock</groupId> <artifactId>androidsvg</artifactId> <version>1.2.1</version> </dependency>
All interaction with AndroidSVG is via the SVG class.
Typically, you will call one of the SVG loading and parsing classes then call the renderer, passing it a canvas to draw upon.
For more information, see the Documentation or read the Javadoc.
Download the latest version and copy it to your libs folder in Eclipse. Then in your app, you can do something like the following.
// Read an SVG from the assets folder SVG svg = SVG.getFromAsset(getContext().getAssets(), filename); // Create a canvas to draw onto if (svg.getDocumentWidth() != -1) { Bitmap newBM = Bitmap.createBitmap(Math.ceil(svg.getDocumentWidth()), Math.ceil(svg.getDocumentHeight()), Bitmap.Config.ARGB_8888); Canvas bmcanvas = new Canvas(newBM); // Clear background to white bmcanvas.drawRGB(255, 255, 255); // Render our document onto our canvas svg.renderToCanvas(bmcanvas); }
If you just want to use an SVG icon in your layout, you can use the supplied SVGImageView custom view class.
AndroidSVG supports the following SVG elements:
<circle> <clipPath> <defs> <desc> <ellipse> <g> <line> <linearGradient> <marker> <mask> <path> <polygon> <polyline> <rect> <solidColor> <stop> <svg> <switch> <symbol> <title> <use> <view>.
<image> <text> <textPath> <tref> <tspan> <pattern> <radialGradient> <style>
For more information on what elements, attributes and properties are supported, see the SVG Implementations Details page.
Please file an bug report and include as much detail as you can. If possible, please include a sample SVG file showing the error.
If you wish to contact the author with feedback on this project, you can email me at androidsvgfeedback@gmail.com.
If you have found AndroidSVG useful and use it in your project, please let me know. I'd love to hear about it!
I was aware of three available when I began this project: syg-android, svg-android-2 (a fork of svg-android) and TPSVG. All three only support a subset of the spec and wouldn't render the files I was using in my app project. The first two appeared to have been more-or-less abandoned. They don't seem to be fixing any bugs or accepting any patches. The third, TPSVG, has been getting updates but does not specify a license, so I felt I could not use it in my commercial app.