-2

i have converted a psd file into svg, it works good at browser but not works on android native applications, how can i do this?

    ImageView imageView = (ImageView)findViewById(R.id.img1);
    imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    //Parse the SVG file from the resource
    SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
    //Get a drawable from the parsed SVG and apply to ImageView
    imageView.setImageDrawable(svg.createPictureDrawable());

This is the code i used to display svg image. it works when i used simple svg images, but it not works converted svg images using illustrator . how can i do?

user3030026
  • 77
  • 1
  • 1
  • 5

1 Answers1

0

I am guessing that your SVG just contains the image from the PSD. Is that the case?

If all that the SVG contains is a bitmap image, then you are not really using SVGs for their proper purpose (vector art). You would be better off just converting the PSD to a JPEG or PNG and loading that into an ImageView.

However, if you are definitely sure you want to load an SVG, then the solution depends on which SVG library you are using.

  1. svg-android: As far as I know, it doesn't support <image> elements, so there is no solution

  2. AndroidSVG: supports <image>, so it should work as long as the device has the memory to load the image. If the image is embedded in the file, you should be fine. If it references an external image, you will need to pass in an SVGExternalFileResolver so it knows how to find the bitmap. See my answer to the following question: https://stackoverflow.com/a/21531168/1292848

Community
  • 1
  • 1
Paul LeBeau
  • 97,474
  • 9
  • 154
  • 181