5

I wrote a program in Android for setting different kinds of images as my background image, but it is not working with svg files. I am not getting any errors, it is not displaying any image and I'm getting a blank screen in my emulator when using svg files. Can any one suggest how to read and display svg files in Android with some code? Or should I convert xml code?

user493244
  • 909
  • 7
  • 19

3 Answers3

5

Getting Batik to run on Android would involve a significant porting effort. There are easier ways to work with SVG on Android. See this answer and this post for details.

Batik uses Java2D to render SVG. Android does not support Java2D, and has its own custom graphics API instead. Batik likely won't work out-of-the-box on Android.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Asaph
  • 159,146
  • 25
  • 197
  • 199
  • 2
    Batik is pure java and open source. If it's not supported natively on the Android platform, you might try compiling it from source and bundling it with your project. – Asaph Nov 10 '10 at 05:51
  • You probably will need some files from Batik. Android doesn't use java class files so you'll probably have to compile the java source for Batik to native Android dex files for them to be useful. It may be a lot of files too. – Asaph Nov 10 '10 at 06:43
0

Another alternative is AndroidSVG (http://code.google.com/p/androidsvg/).

Paul LeBeau
  • 97,474
  • 9
  • 154
  • 181
0

If you can afford to only support Android versions greater than 3, then you could use a Webkit instance to render SVG, as the Android Webkit browser finally has SVG support compiled in.

Alternatively, if you do not require support for scripting or animation, you try using this library: http://code.google.com/p/svg-android/

jbeard4
  • 12,664
  • 4
  • 57
  • 67
  • I think this answer is referring to browser-based apps on android, as opposed to native-apps on android ? – dsdsdsdsd Apr 22 '16 at 14:09