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:
It simply works like this:
- You upload your SVG.
- You provide the base size. Which becomes the “mdpi” version of your SVG. Let’s suppose you provided 32px.
- The page will then give you back single zip file containing these files and folders:
|Folder and file||Image size|
|2. drawable-mdpi/your_file.png||32px (base)|
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