Tutorial about how to integrate SVG file in Android Studio. Open Android Studio and create a project (see here how). Application name for this example is SVG. In project structure in app -> res  right click  -> New -> Directory create New Directory. Integrate SVG in Android Studio 1 Name New Directory: raw. Integrate SVG in Android Studio 2 Click here to download the archive with SVG file. Unzip the archive and put the file android.svg (with copy-paste) in the newly created folder raw. Integrate SVG in Android Studio 3 Click here to download the jar file and put it (with copy-paste) in the libs folder of our project. Right click on app folder of project and choose Open Module Settings. Integrate SVG in Android Studio 4 Click on Dependencies tab, click on + and choose File dependency. Integrate SVG in Android Studio 5 Write the path of downloaded svg-android.jar. Integrate SVG in Android Studio 6 In app -> java ->MainActivity.java file write the following code:
        // 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);
Click on each of the words in red and press Alt + Enter. Integrate SVG in Android Studio 7 Run the application and see the result. The SVG file was successfully integrated. Integrate SVG in Android Studio 8 Download here the project with all files. Download here the application for mobile phone. Watch the video tutorial to integrate SVG file in  Android Studio:

For further questions leave a message.

9 Comments

You can follow any responses to this entry through the RSS 2.0 feed.

Hi, I follow above step, up to
Write the path of downloaded svg-android.jar.

I just cannot allocate the svg-android.jar
please help me out.

Many thanks.

Best regards,

Peter

i just followed the steps you have given. But when i run the apk file, i can just see a blank screen in the emulator. The SVG image did’nt show up.

Thank you.

    Hi sir I am also facing the same problem so have you got the answer.

is this jar file open source?

Try using this repo. It’s newer and it’s open source! https://github.com/BigBadaboom/androidsvg
Cheers

When I am Trying to integrate .svg image it generates apk successfully but show error as Follows in Log cat
02-10 17:55:22.261 2813-2813/? I/art: Not late-enabling -Xcheck:jni (already on)…

This is very nice that how to use .svg in android. It’s great

I make andorid in android studio and export it. I install apk. File in my phone it finish but it’s not show on my phone.Why problem? Please tell me. Thank you.

Leave a Reply to Nandy Cancel reply

Your email address will not be published. Required fields are marked *

Blue Captcha Image Refresh

*