17

I want to convert my png file to xml resource that can be accepteed by android. I converted it by using the website below.

https://convertio.co/fr/png-svg/

Then I downloaded it then put it in resource directory and changed type to xml, but android didn't accept it of course.

Community
  • 1
  • 1
Lina Hammami
  • 373
  • 1
  • 4
  • 22
  • 4
    This site seemed to convert the png to svg a little better. https://image.online-convert.com/convert-to-svg – Just The Highlights Mar 01 '19 at 15:31
  • 2
    Does this answer your question? [Easiest way to use SVG in Android?](https://stackoverflow.com/questions/30923205/easiest-way-to-use-svg-in-android) – Ryan M Apr 10 '20 at 01:34

2 Answers2

24

You can import a svg asset and convert it into a vector.

Click on new vector asset and you will have two options , psd and svg. Import your svg file and it will be stored as a xml file.

Dishonered
  • 8,449
  • 9
  • 37
  • 50
10

In current Android Studio version (3.6 rc1), you can import png image directly. File-> New-> Image Asset.

In the Asset Type, select Image, provide path to your image file and click on Next and Finish buttons.

Android Studio would do the conversion for you.

Naresh
  • 369
  • 2
  • 11
  • 1
    I am selecting my PNG file for the foreground tab in Image Asset - but its not creating the `ic_launcher_foreground.xml` file. It is creating the `ic_launcher.xml` and the `ic_launcher_round.xml` - but if I use PNG files for either foreground or background, the corresponding xml files not being generated. If I change to the asset type to `color` or `art clip`, it will generate the foreground/background xml files. The problem for PNGs is that in the `ic_launcher/ic_launcher_round` xml files, both reference the foreground/background xml files, which don't exist causing the build to fail. – rolinger Apr 19 '20 at 00:48
  • @rolinger : What do you want to use the png file for? – Naresh Apr 26 '20 at 17:14