View on GitHub

AndroidSVG

SVG rendering library for Android

Release Notes

1.3

The 1.3 release is now available.

For Android Studio users

If you haven't already, remember to add Maven Central to the repository list in you main/root build.gradle file.

    repositories {
        google()
        jcenter()
        mavenCentral()
    }

Then in your app module build.gradle file, add:

    implementation 'com.caverock:androidsvg-aar:1.3'

For people who need the JAR

h3> The Maven POM dependency entry is:
<dependency>
  <groupId>com.caverock</groupId>
  <artifactId>androidsvg</artifactId>
  <version>1.3</version>
</dependency>

Downloads

You can download the AAR and/or JAR directly from the Maven Central repository.

Changes in this release

  • Issue #11: Added support for passing extra CSS at render time, and also when using SVGImageView. This enables the long-requested ability to re-colour SVGs. To use this feature, you need to use one of the new renderToX() methods that take a RenderOptions parameter.
  • Added support for external stylesheets using: (a) <?xml-stylesheet> processing instruction, and (b) CSS @import (thanks to David Gileadi).
  • Issue #18: Added support for all CSS Selectors Level 3 pseudo classes (:not(), :nth-child(), :last-of-type, etc). Some are supported but never match because they don't make sense for us (eg. :checked)
  • Issue #94: Implemented new way to do clip paths. The new method works on all 4.4 (Kitkat) and later devices. Clip paths are now more accurate, handle clip-rule properly, and work for renderToPicture(). Works around the bug in 6.0 that mangles clipPaths on canvas.retore().
  • Issue #45: Implement masks in a much better way using layer compositing. Mask processing is *much* faster now.
  • Issue #38: Implemented CSS3 Color keyword "transparent", and functions rgba(), hsl() and hsla(a). Implemented CSS4 Color keyword "rebeccapurple", and #RGBA and #RRGGBBAA hex forms.
  • The SVGPositioning class has been renamed to PreserveAspectRatio so that it makes more sense when used with the new RenderOptions class.
  • Issue #26: Bad property values no longer throw an exception when parsing. They are now just ignored.
  • Fixed bug with fill-opacity not affecting gradients as it should.
  • Issue #61: CSS selector match now uses a nodeName string field rather than using reflection. This should mean that workaround ProGuard rules are no longer needed to avoid obfuscation breaking CSS matching.
  • Issue #122: Support both SAXPsrser and XmlPullParser depending on whether we want to support entity expansion or not. Now defaults to XmlPullParser. Parser is now much less prone to the billion laughs attack.
  • Fixed issue with the calculation of initial root viewport.
  • Issue #118: Fixed bug with text-anchor alignment wasn't being recalculated if x was specified on a child tspan.
  • Fixed build issues (thanks to Jorge Ruesga).
  • Issue #121: Fixed fault with images that have masks that are also images.
  • Changed class attribute parser to not throw an exception if it finds a bad class name.
  • Improved marker angle calculation when the path segments at a point do an exact 180deg turn.
  • Changed the default font family to serif to match browser behaviour.
  • Fixed bug where FuncIRI references with quoted strings, for example url("foo") and url('foo'), were not correctly parsed.
  • Issue #78: Fixed bug where renderToCanvas(Canvas canvas, Box viewPort) not rendering the SVG in the correct place.
  • Issue #50: Canvas state wasn't being saved before rendering root element.
  • Issue #99: Fixed NPE in <linearGradient> and <radialGradient when stop was missing offset attribute (thanks to hazzeh).
  • Added support for image-rendering attribute.
  • Issue #89: Added support for SVG2 href attributes without the xlink namespace.
  • Issue #105: Fixed incorrect parsing of style property values that include whitespace (eg. font-family).
  • Fixed parsing of short (#FFF) CSS colours (thanks to Ofri Wolfus).
  • Fixed bug calculating bounding box of <line> (thanks to francis).
  • Issue #62: Changed internal arcTo() function to use floats. The double version was triggering an Android (JIT?) bug in some situations.
  • Issue #81: Fixed bug with empty <title> and <desc> elements (eg. <title/>) causing NPEs.
  • Migrated to Gradle and added Sonatype upload task (thanks to Nic Dahlquist).
  • Fixed a couple of bugs in the internal NumberParser class.
  • Cache id lookups in getElementById(). Speeds up rendering of some files significantly.
  • Convert path enumerator to use primitive arrays instead of lists. Achieves modest speedup in most cases (thanks to Markus Junginger).
  • Better handling of input streams in getFromResource() and getFromAsset().
  • Converted internal NumberParser.parseNumber() to return a float rather than a NumberParser. Results in fewer memory allocations and much higher speed (thanks to Markus Junginger).
  • Fixed some multi-threading issues in lazy-initialised keyword maps (thanks to papp.robert.s), and in element and attribute maps (issue #145 fix thanks to brudaswen).