CNorris
CNorris

Reputation: 308

Can Android Drawables defined in XML contain a path?

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?

Upvotes: 5

Views: 3208

Answers (3)

cyon
cyon

Reputation: 9538

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>

Upvotes: 3

Dustin
Dustin

Reputation: 2154

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/

Upvotes: 2

Graham Borland
Graham Borland

Reputation: 60701

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

Upvotes: 3

Related Questions