Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I export Android XML vector drawables to another format?

I want to recreate my app for iOS and the icons in Android are XML vectors with the "android:pathData" attribute. How do I convert these to an image that I can place into Xcode and use (preserving transparency)?

I have searched for a solution and found nothing and read the article on the Android Developer site on Vector Asset Studio but found nothing about exporting these drawables to something I can import into Xcode.

like image 669
Questioner Avatar asked Jan 29 '16 10:01

Questioner


People also ask

Is XML a vector file?

svg: The Scalable Vector Graphics format is based in XML (a markup language used widely across the Internet that's readable by both machines and humans). It's useful for the web, where it can be indexed, searched, and scripted.

What are vector Drawables in android?

A VectorDrawable is a vector graphic defined in an XML file as a set of points, lines, and curves along with its associated color information. The major advantage of using a vector drawable is image scalability.

What is not an advantage of using vector Drawables?

The drawback is that they might take longer to draw, etc since there's more of parsing and drawing going on than just using a bitmap. This should although be neglectable if you keep your vectors simple.


1 Answers

I did it by creating an SVG file and copying the value of the pathData attribute of the path element in the XML file and pasting it into the d attribute of the path element in the SVG file. I then converted it to PNG using ImageMagick.

So

<path android:pathData="[Path Data]">

becomes

<path d="[Path Data]">.

Then

convert -background none image.svg image.png

in the command line.

If there is a better way of doing this please post it.

like image 184
Questioner Avatar answered Oct 13 '22 05:10

Questioner