Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

xml

png

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.

like image 748
Lina Hammami Avatar asked May 16 '17 11:05

Lina Hammami


People also ask

How do I convert a PNG file to XML?

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.

What is Android XML file?

XML tags define the data and used to store and organize data. It's easily scalable and simple to develop. In Android, the XML is used to implement UI-related data, and it's a lightweight markup language that doesn't make layout heavy. XML only contains tags, while implementing they need to be just invoked.


2 Answers

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.

like image 191
Dishonered Avatar answered Sep 28 '22 07:09

Dishonered


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.

like image 40
Naresh Avatar answered Sep 28 '22 07:09

Naresh