SVG Kit for AndroidSvg Kit for Android

SVG Kit for Android is a flexible and quite fast library supporting SVG Tiny specs.

Every time you need to paint some icons, backgrounds, charts, document pages, diagrams in vector format, you need a way to do this easily and possibly without NDK, cross-compilation issues, reducing performance, etc.

svg

The amazing library developed by our company just do it: no extra code, no extra libraries, no tuning.

A few examples:

SVG as resource:

mImageView.setImageBitmap(
      SVGHelper.useContext(this).open(R.raw.star).getBitmap());

SVG in external file:

File file = new File(
    Environment.getExternalStorageDirectory() + "/svg/star.svg");
mImageView.setImageBitmap(
    SVGHelper.noContext().open(file).getBitmap());

And even more:

SVG from string:

mImageView.setImageBitmap(SVGHelper.noContext()
.open(
      "<svg viewBox=\"0 0 100 100\">\n" +
      "<path d=\"M50,3l12,36h38l-30,22l11,36l-31-21l-31,21l11-36l-30-22h38z\"\n" +
      "fill=\"#FF0\" stroke=\"#FC0\" stroke-width=\"2\"/>\n" +
     "</svg>\n")
.getBitmap());

Why SVG Kit for Android

We have evaluated a lot of libraries, many of which were either too slow but over-featured (like the legendary Apache Batik) or too complicated in maintenance (like NDK, librsvg and issues with the proper compilation for all supported platforms and architectures). We just wanted to show the vector background.

So, we have decided to make our own library. And even more, we have added a few abilities that are not supported by "huge" libraries. Even, radial gradients are supported in our library.

Features of SVG Kit

We tried to make it as small as possible; no advanced features from SVG 1.2 Full specs are supported. We suppose we don't need animations, compositions, JavaScript or user input, we want to use just vector background or icon.

To summarize, now we have:

  • Pretty small.
  • Pure Java.
  • Reliable and fast.
  • CSS support.
  • Gradients (including radial), transformations and paints.
  • Fonts, texts and text spans.
  • Drawing primitives, paths and polygons.
  • Strokes and fills, including alpha, dashes, joins and other.
  • XLink support included.
  • Raster images in SVG support (external, from assets or embedded).
  • SVG filters initial support.
  • SVG and SVGZ support.

Moreover, we have tested huge SVG files with dozens of megabytes each. Depending on the SVG files and transport (local or from Internet) it might be "pretty fast" or "acceptable", but it really works in all cases.

The following features are not supported:

  • Declarative animation for SVG.
  • Interactive and dynamic SVG documents.
  • JavaScript.
  • Raster images in strange formats.
  • HTML tags around.

It is just a small, fast and easy-to-use library which was designed to support "pure vector" icons, backgrounds and etc. No overloading on this stage. In case anybody requests it - our team will expand the library according their needs. It's not a big problem for our team.

Support

Support Email: svg@scand.com

Scand is providing a full range of custom software development services. We develop software for dozens of clients world-wide, and we would be glad to do this for you. You are welcome to submit your project/product request using our contact form. We will contact you shortly to clarify all requirements.