asolfre / androidsvg

Automatically exported from code.google.com/p/androidsvg
0 stars 0 forks source link

androidsvg

Automatically exported from code.google.com/p/androidsvg

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.

Downloads

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.

Editor support

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.

How do I use AndroidSVG?

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>

API Introduction

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.

Usage example

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.

What features of SVG are supported?

AndroidSVG supports the following SVG elements:

Fully supported

<circle> <clipPath> <defs> <desc> <ellipse> <g> <line> <linearGradient> <marker> <mask> <path> <polygon> <polyline> <rect> <solidColor> <stop> <svg> <switch> <symbol> <title> <use> <view>.

Supported with some limitations

<image> <text> <textPath> <tref> <tspan> <pattern> <radialGradient> <style>

Not supported at all

For more information on what elements, attributes and properties are supported, see the SVG Implementations Details page.

Find a bug?

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!

Aren't there already several SVG renderers for Android?

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.