Press on the image to return to the main documentation page.
SVG
Written by Andrew Graham
This library supports a subset of the SVG Basic 1.1 specification. Typically, you can just load your vector artwork in a suitable program and then save it as a SVG Basic 1.1 file and it will work fine.
By using vector art, the pain of supporting various screen sizes and densities in Android can be reduced.
These are the features of SVG Basic not supported: Raster images (bitmaps). Symbols, conditional processing. Patterns. Masks, filters and views. Interactivity, linking, scripting and animation.
Bounds and Limits It is useful when working with an SVG to know the rectangular bounds of the content. The document (artboard) bounds themselves are typically not useful for this, as few artists will size the content to those bounds. Instead, we offer two approaches:
Bounds If there is a layer in the artwork called "bounds", it will not be drawn. Rather, the first rectangle found in that layer will be interpreted as the bounds of the artwork. This makes it easy for an artist to specify the right bounds right in the artwork without the developer having to do additional work.
Limits While the parser is reading the SVG, it estimates the bounds of the artwork from what is read. This may not always be correct, but can often be relied upon for simple artwork.
Version 1.0 of this library was a very thin wrapper of the svg-android library which it required as an external component to be referenced as a Lib by Basic4android. svg-android
This version of the library is a very thin wrapper of the svg-android-2 library and the source code for that is compiled into this library so no external component is needed. This fork is used as the original author seems to have not reponded to bug fix requests so another programmer has created this fork and applied some fixes and improvements. Support transforms in g tags Support transform lists (e.g. transform="rotate(..) scale(..) ...") Support for arcs in paths Support implied commands in paths Support for named colors Support for text (limited, but including font-size, type-face, and text alignment) Support for stroke-dasharray for dotted/dashed lines svg-android-2
The svg-android library is released for use under the Apache License Version 2.0. Apache 2.0
Unfotunately the svg-android library is not always very informative about SVG files that it cannot parse. Sometimes it will just throw a NullPointerException without any further information as to where in the SVG file the problem lies. Other times it may throw an exception whose message includes the line and column where the error is located in the SVG data file.
This is a compact and straightforward object for parsing simple SVG files and rendering them in an Android Canvas or as a PictureDrawable that may be assigned to the Background of a View.