Android SVG Support

Does Android support SVG? any example?

+75
android svg
Oct 08 2018-10-10
source share
11 answers

The most complete answer is:

  • Android 2.x default browser does not support SVG.
  • Android 3+ browsers support SVG by default.

To add support for SVG in version 2.x of the platform, you have two main options:

  • Install a more convenient browser (for example, Firefox or Opera Mobile - support SVG)
  • Use JavaScript polyfill, which can parse SVG and display it on HTML5 canvas

The first option is fine if you are just trying to make SVG work for personal use or with a limited (controlled) set of users. This is not a great option if you want to use SVG when targeting a large, uncontrolled user base.

In the latter case, you want to use polyfill. Many JavaScript libraries are available today that can edit SVGs and display on canvas. Two examples:

Using polyfill, you can display your SVG in the ditches in all versions of Android 2.x.

For a more complete example of this approach, you can refer to this blog post that discusses the use of canvg polyfill to create Kendo UI DataViz Pictures (based on SVG) running on Android 2.x. Hope this helps!

+55
Feb 17 '12 at 18:11
source share

There is a new open source library that supports downloading and drawing SVG Basic 1.1 files: https://github.com/pents90/svg-android . Performance is good since the actual drawing is handled initially by the android.graphics.Picture object.

+22
May 11 '11 at 22:56
source share

Currently, some people, including me, are working on it independently.
You can find a working solution in these articles:
Android ImageView with SVG support.
Android ImageView and Drawable with SVG support

+8
Dec 14 '10 at 10:45
source share

There is a new library (in active development) androidsvg , which allows you to include svg images directly in projects. This has the advantage of defining SVGImageView , which allows svg to be included directly in the xml layout.

Finally, enabling svg in android is simple.

Read More: Stack Overflow Message

+8
Nov 03 '13 at 0:04
source share

Android supports vector images: https://developer.android.com/reference/android/graphics/drawable/VectorDrawable.html

And there is Android SVG for VectorDrawable Converter: http://inloop.imtqy.com/svg2android/

+8
Jul 27 '15 at 15:30
source share

I briefly reviewed https://code.google.com/p/androidsvg/ . While showing all the svg files on which I sketched them. It looks promising.

+2
Jul 11 '14 at 6:46
source share

I just launched the Github repository and a sample repo for my own TPSVG library, which I originally created specifically for my application.

https://github.com/TrevorPage/TPSVG_Android_SVG_Library

https://github.com/TrevorPage/TPSVG_Example1

+1
May 28 '12 at 22:33
source share

I know that my solution is somewhat hardcore, but it works fine, does not require any external libraries (at least not in the final code) and is very fast.

1) Just take an existing SVG download library, such as, for example, svg-android-2 (which is the svg-android plug mentioned in another answer, just with additional features and fixes): https://code.google. com / p / svg-android-2 /

2) Write a simple application that will do nothing but download and display your SVG image.

3) Modify the SVG download library to print Java code that creates the Picture class or stores it in the String variable.

4) Copy the Java code thus obtained into the application you are writing.

To learn more about this technique and download the source code for the example, go to my blog: http://androiddreamrevised.blogspot.it/2014/06/transforming-svg-images-into-android.html

You can get a working example of this technique from Google Play: https://play.google.com/store/apps/details?id=pl.bartoszwesolowski.svgtodrawablesample

Here is an example of a commercial application created using this technique (Milan metro map): https://play.google.com/store/apps/details?id=pl.bartoszwesolowski.atmmetroplan

Pay attention to how quickly the map loads and how much it looks, even when it is enlarged.

+1
Jun 27 '14 at 18:20
source share

Firefox for Android supports SVG.

0
May 03 '11 at 6:12
source share

Opera Mobile for Android supports svg and Opera Mini supports static svg content.

0
May 03 '11 at 8:54 am
source share

Check out Supported vector wrapping . Android Studio has a tool for converting SVG files to .XML files.

when using AppCompat with ImageView (or subclasses such as ImageButton and FloatingActionButton), you can use the new application: the srcCompat attribute for links to vector drawings (as well as any other available for android: src):

As in Android Support Library 23.3.0, support for vector drawings can only be downloaded through the application: srcCompat or setImageResource ()

0
Jul 02 '16 at 7:34
source share



All Articles