How to convert a png file to xml resource by Android? [closed]
Asked Answered
R

2

19

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.

Retina answered 16/5, 2017 at 11:21 Comment(2)
This site seemed to convert the png to svg a little better. image.online-convert.com/convert-to-svgImperial
Does this answer your question? Easiest way to use SVG in Android?Peristyle
G
29

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.

Galipot answered 16/5, 2017 at 11:25 Comment(0)
C
11

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.

Canonist answered 7/1, 2020 at 8:52 Comment(2)
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.Goode
@Goode : What do you want to use the png file for?Canonist

© 2022 - 2024 — McMap. All rights reserved.