SVG support on Android

前端 未结 11 1942
一向
一向 2020-11-28 23:06

Does Android support SVG? any example?

11条回答
  •  感动是毒
    2020-11-28 23:39

    I know my solution is somewhat hardcore, but it works great, doesn't require any external libraries (at least not in your final code) and is extremely fast.

    1) Just take an existing SVG loading library, such as for example svg-android-2 (which is a fork of svg-android mentioned in another answer, just with more features and bugfixes): https://code.google.com/p/svg-android-2/

    2) Write a simple app that will do nothing else but load and display your SVG image.

    3) Modify the SVG loading library, so that it prints the Java code that creates the Picture class or saves it in a String variable.

    4) Copy-paste the Java code obtained this way into the app you are writing.

    To get more information about this technique and download sample source code, 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 here: https://play.google.com/store/apps/details?id=pl.bartoszwesolowski.svgtodrawablesample

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

    Notice how fast the map loads and how pretty it looks, even when magnified.

提交回复
热议问题