1

I have eps image files. i have converted to .svg by online converter nut now this converted svg is not getting displayed on the screen. (Code works with other original svg image).

Is there something like we can not use converted svg images in android apps?

Here is my code:

    public void onCreate(Bundle savedInstanceState) 
    { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    view = new GestureImageView(this);       
    svgImg=sVGParser.getSVGFromResource(getResources(),R.raw.american); 
    view.setImageDrawable(svgImg.createPictureDrawable()); 
    view.setLayoutParams(params); 
    view.setMaxScale(15f); 
    ViewGroup layout = (ViewGroup) findViewById(R.id.layout); 
    layout.addView(view); 
    } 
swiftBoy
  • 35,607
  • 26
  • 136
  • 135
  • At the moment Android does not support SVG rasterization, please! check [this](http://stackoverflow.com/questions/6667536/does-android-have-native-support-svg-image-as-drawable-resources-icons) – swiftBoy Apr 01 '13 at 10:34
  • Thanks for the reply. :) If i am not wrong then rastering svg image means converting svg image(vector format image) into no-vector formats like png, jpeg but i am not doin that. I have simply converted ".eps" image into ".svg" that too by online converter (not in the code) So in my code if normal .svg image is dispoalying then converted image also should get displayed. But it is not. Is it possible in the way i am doing it? – Priyanka P. Apr 01 '13 at 11:48
  • can you post the code snip where you getting stuck? I am wondering whether the problem is with your android code or the converted image? – swiftBoy Apr 01 '13 at 11:57
  • public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); view = new GestureImageView(this); svgImg=sVGParser.getSVGFromResource(getResources(),R.raw.american); view.setImageDrawable(svgImg.createPictureDrawable()); view.setLayoutParams(params); view.setMaxScale(15f); ViewGroup layout = (ViewGroup) findViewById(R.id.layout); layout.addView(view); } Actually the code is too big as i have added zoom in and ut logic. – Priyanka P. Apr 01 '13 at 12:49
  • Please don't paste code into comments! – WarrenFaith Apr 01 '13 at 17:40

2 Answers2

1

More than likely the problem is with the SVG generated by the online converter you used.

It appears as if you are using svg-android. You might have more success with AndroidSVG which supports more of the SVG spec.

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

I would personally suggest you not to use SVG as Android does not support SVG rasterization, you may like to read more discussion here.

but if you really got stick with svg then here are some useful solutions may help you.

Scaling SVGs in Android

Is there any lite SVG viewer for Android

svg image files android

Here are some beautiful tutorials for display SVG in android

Android ImageView and Drawable with SVG Support

Android. ImageView with SVG Support

I could have created a sample code for this but I am in Xcode now.

Community
  • 1
  • 1
swiftBoy
  • 35,607
  • 26
  • 136
  • 135