40

Are there online tools to convert png file to vector drawable files (xml in Android)?

I have few pngs that I was using for icons & various places in my app. So, now I want to convert them to xmls. Is it possible to do so?

Swati Garg
  • 995
  • 1
  • 10
  • 21
  • you don't. That is not how Android handles png. XML drawables are custom drawable files that you write, like shapes, colors, etc more like a custom view. You need to generate assets with your PNG. Use this -> https://romannurik.github.io/AndroidAssetStudio/. Also it would be great if you elaborate on your query. – Deepak kaku Oct 05 '18 at 18:04
  • I have edited my query. Also, I am not able to convert my png to vector drawable using the above link. https://github.com/project-travel-mate/Travel-Mate/blob/master/Android/app/src/main/res/drawable/aed.png – Swati Garg Oct 05 '18 at 18:09
  • Try the solution I provided below. hopefully it helps – Deepak kaku Oct 05 '18 at 18:20
  • This does not really make sense except for very, very few exceptions. The reason has nothing to do with Android, but with how graphic formats work. Converting a raster graphic format into a vector format simply does not make sense. It will produce an output, but that output will have none of the benefits of a vector graphic. It cannot be scaled like a _real_ vector graphic but it is equally expensice to draw. That does not make sense. – arkascha Dec 06 '21 at 18:06

1 Answers1

88

Ok, so you can convert PNG to Android vector drawable following these steps

  • Step 1: Convert PNG to SVG (Scalable Vector Graphics)

https://www.autotracer.org/

Or you can use any online converter of your choice

http://a-student.github.io/SvgToVectorDrawableConverter.Web/

Alternatively you can also use Android studio to generate Vector drawables from SVG generated in Step 1.

  • Inside Android studio, right click on your drawable folder New > Vector Asset

This will open up the Android studio Vector asset generator. Select a local SVG file (the one you generated online)

enter image description here

You can also refer to this post https://stackoverflow.com/a/35402459/6142219

Deepak kaku
  • 1,218
  • 9
  • 15
  • 2
    This png to svg convert is by far the best one, already had tried a lot of different options and this one is in a total different league! Very glad to found this answer! – ggrana Sep 09 '19 at 01:50
  • @ggrana Perhaps you can help me... I am trying to convert https://ibb.co/SdZjjTH to xml using https://www.autotracer.org/ and http://inloop.github.io/svg2android/. It works, but when I try to use it in my app, the app crashes. Can you check if it works for you? Thanks! – Yossi Feb 08 '20 at 16:28