7

i want to display a svg image in Image View. First i download svg-android 1.1.jar and save in lib file and also save an svg image in res/raw folder and i used follwing code to display svg image

   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Create a new ImageView
    ImageView imageView = new ImageView(this);
    // Set the background color to white
    imageView.setBackgroundColor(Color.WHITE);
    // Parse the SVG file from the resource
    SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.android);
    // Get a drawable from the parsed SVG and set it as the drawable for the ImageView
    imageView.setImageDrawable(svg.createPictureDrawable());
    // Set the ImageView as the content view for the Activity
    setContentView(imageView);
}

but when i run this program i get a blank screen instead of svg file while i test the code using android devices, but when i test using emulator the image displays. How can i get the svg image in android device?

Shakeeb Ayaz
  • 6,200
  • 6
  • 45
  • 64
user3030026
  • 77
  • 1
  • 1
  • 5

0 Answers0