Display SVG image in image view in Android

I want to display svg image in image view. First, I download svg-android 1.1.jar and save it in the lib file, and also save the svg image in the res / raw folder, and I used the follwing code to display the 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 the svg file, and I check the code using Android devices, but when I test using the emulator, the image is displayed. How can I get svg image in android device?

+6
source share

All Articles