Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting SVG file to Android Vector Drawable XML while keeping the group structure in place

I want to convert SVG files to Android Vector Drawable XMLs. I need the structure of the SVG. To the extend that the SVG groups multiple elements together, I need that grouping to also be reflected in the Android Vector Drawable.

Unfortunately, the tools I found to do SVG to Vector Drawable conversions try to minimize the file size in a way that gets rid of existing grouping in the structure of the file.

Is there a smart way to do the conversion that leaves the grouping tree intact?

like image 944
Christian Avatar asked Sep 27 '17 20:09

Christian


People also ask

Can we use SVG in drawable Android?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.

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.

Are SVG vector files?

What is an SVG file? Scalable Vector Graphics (SVG) is a web-friendly vector file format. As opposed to pixel-based raster files like JPEGs, vector files store images via mathematical formulas based on points and lines on a grid.


1 Answers

Update 2019: There is no need of using any external tool or Heck as pointed by older answers. Android Studio's Asset Studio allows to convert SVG/ PSD to vectors

  • Right click on app folder-> New Vector Asset
  • Select second option in radio button to create vector from local file as shown in below image.
  • Click on folder icon to load local SVG file and it will automatically convert that into vector:

enter image description here

like image 99
Hitesh Sahu Avatar answered Oct 06 '22 04:10

Hitesh Sahu