SVG to Android Drawables Package in PNG

Hello there,
Last year when I was making an app for my company, I was having trouble trying to import SVG directly into Android Studio. I tried Vector Drawables too but the result wasn’t perfect. Maybe this is not the case now. So at that time, I made a small script that converts SVG into Android Drawables Package in PNG’s and I used that in my project.

For all the fellow Android developers, I published the script here:
https://w3goodies.com/export-images/svg-to-android.html

It simply works like this:

  1. You upload your SVG.
  2. You provide the base size. Which becomes the “mdpi” version of your SVG. Let’s suppose you provided 32px.
  3. The page will then give you back single zip file containing these files and folders:
Folder and file Image size
1. drawable-ldpi/your_file.png 24px
2. drawable-mdpi/your_file.png 32px (base)
3. drawable-hdpi/your_file.png 48px
4. drawable-xhdpi/your_file.png 64px
5. drawable-xxhdpi/your_file.png 96px
6. drawable-xxxhdpi/your_file.png 128px

The script makes the resolution of image very high before converting so the quality of exported images will be very good.
Normally, you could directly replace the contents of zip file into your Android App “app/src/main/res” folder.

I hope this tool makes the work of my fellow Android Developers, some easy. Happy coding!


If you also code for iOS you can find similar post on iOSProgramming sub reddit: https://forums.raywenderlich.com/t/svg-into-ios-images-package-in-png/37964

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.