Convert PNG file to XML drawable icon
Updated: Dec 13, 2022
I saw lots of traffics on this article but I noticed this page doesnโt cover the problem enough.
And one more things to update, the original post of this was actually 4 years old ๐ .
If you are reading this article, I would assume you know what you are doing. But let me go through this part.
I want you to keep in mind that converting png to svg, eventually to XML, is not a good solution. You better avoid this. Always try to look for svg format for sure. And keep .ai file or figma files to generate svg at any time. SVG does a very important role in multi-resolution world, which PNG or JPG cannot do.
Converting PNG to SVG is possible and sometimes you donโt have a nice option to choose rather than this way. Still, you should be aware of problems with resolutions.
-
Prepare PNG or JPG files. Any of your static images. I assume most of them are icon images but try to optain as high resolultion as possible.
-
We must convert images to SVG first. There are several options Iโve tried. But
Adobe Express
was the best option so far.- Adobe Express
- Web upload version. It works pretty nice. But you need a sign-up.
- SVGCode
- Progressive Web app based. Sorta okay.
- Adobe Express
-
Once you have SVG files, itโs literally done because XML is just another format of describing Vectorized images.
- Android Studio
- Open Asset Studio. You can load SVG or PSD file. And the program will auto convert for you.
- SVG to Vector Drawable
- If you want to manually convert your images (I suppose you barely need to), you can try this web site. I used this a lot before the Android Studio added Asset Studio support. Just make sure you are using correct width and height unit (mostly dp) and there wonโt be many chances you really need to change Bitmap tracer preset.
- Android Studio
Happy Hacking ๐
Leave a comment