Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Android Drawables defined in XML contain a path?

Tags:

java

android

svg

I use Inkscape to create the art assets in my app.

At the moment I have to create bitmaps from my (simple) Inkscape vector art before I can use the images in my app.

I would prefer to be able to create an XML Drawable that contains the paths from my art. Can this be done?

like image 365
CNorris Avatar asked Apr 12 '12 08:04

CNorris


3 Answers

Not directly, but there are some third-party workarounds. Have a look at this guide, for example.

like image 71
Graham Borland Avatar answered Sep 26 '22 16:09

Graham Borland


With the release of Android 5.0 Lollipop (API 21) this is now possible using VectorDrawable

<vector xmlns:android="http://schemas.android.com/apk/res/android"
     android:height="64dp"
     android:width="64dp"
     android:viewportHeight="600"
     android:viewportWidth="600" >
     <group
         android:name="rotationGroup"
         android:pivotX="300.0"
         android:pivotY="300.0"
         android:rotation="45.0" >
         <path
             android:name="v"
             android:fillColor="#000000"
             android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
     </group>
 </vector>
like image 35
cyon Avatar answered Sep 24 '22 16:09

cyon


I'm trying the same thing. This project has a pure Java impl. It works OK for simple objects, but failed on some complicated objects. It does have a method to convert SVG path Strings to Path objects...

https://code.google.com/p/svg-android/

like image 32
Dustin Avatar answered Sep 26 '22 16:09

Dustin