Vector graphics in Android

Check out svg-android - it's a relatively new library and it only supports SVG Basic, but it's the library used to draw Androidify. There are examples on the homepage on how to get a Drawable from an SVG which sems to be what you're looking for.


Creating Vector Drawables.


I know this question is old, but I came across this same requirement and I'm happy to learn that Android 5.0 supports vector drawables now. You can use <vector> tag and path data to create vector drawables and it works like a charm on API-21. Here is an example that produces a vector image in the shape of a heart.

<!-- res/drawable/heart.xml -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:height="256dp"
    android:width="256dp"
    android:viewportWidth="32"
    android:viewportHeight="32">

    <!-- draw a path -->
    <path android:fillColor="#8fff"
        android:pathData="M20.5,9.5
                    c-1.955,0,-3.83,1.268,-4.5,3
                    c-0.67,-1.732,-2.547,-3,-4.5,-3
                    C8.957,9.5,7,11.432,7,14
                    c0,3.53,3.793,6.257,9,11.5
                    c5.207,-5.242,9,-7.97,9,-11.5
                    C25,11.432,23.043,9.5,20.5,9.5z" />
</vector>

The only problem I faced so far is that, it is not included in the support libs, and so you cannot make use of them in lower APIs. The wonderful thing is that, you can even animate vector drawables now. Here is an example.

<!-- res/drawable/vectordrawable.xml -->
<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>

Read more about vector drawable animation here.