SVG support on Android

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

Does Android support SVG? any example?

相关标签:
11条回答
  • 2020-11-28 23:30

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

    And there exists an Android SVG to VectorDrawable Converter: http://inloop.github.io/svg2android/

    0 讨论(0)
  • 2020-11-28 23:32

    I've had a brief look at https://code.google.com/p/androidsvg/. So far displayed all svg files I threw at it. Looks promising.

    0 讨论(0)
  • 2020-11-28 23:38

    Check out Support vector drawable. Android studio has a tool to convert SVG files to .XML files.

    when using AppCompat with ImageView (or subclasses such as ImageButton and FloatingActionButton), you’ll be able to use the new app:srcCompat attribute to reference vector drawables (as well as any other drawable available to android:src):

    As of Android Support Library 23.3.0, support vector drawables can only be loaded via app:srcCompat or setImageResource()

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-28 23:42

    I've just chucked up a Github repo and example repo for my own TPSVG library, which I originally created specifically for an application of mine.

    https://github.com/TrevorPage/TPSVG_Android_SVG_Library

    https://github.com/TrevorPage/TPSVG_Example1

    0 讨论(0)
  • 2020-11-28 23:43

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

    0 讨论(0)
提交回复
热议问题