Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dashes stroke-dasharray in Android Vector

How to add dashed line on Android Vector Drawable? It seems "stroke-dasharray" from svg is not supported in Android Vector. Is any other way to do it? My drawable that I want to make dashed:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="61dp"
    android:height="160dp"
    android:viewportWidth="61.0"
    android:viewportHeight="160.0">
<path
    android:pathData="M2,159C6,81.5 38,21 57,4"
    android:strokeColor="#FFCF4D"
    android:fillColor="#00000000"
    android.stroke-dasharray="1"
    android:strokeWidth="3"/>
<path
    android:pathData="M49,2L59,2L59,12"
    android:strokeColor="#FFCF4D"
    android:fillColor="#00000000"
    android:strokeWidth="3"/>

like image 485
Tim Avatar asked Aug 26 '17 09:08

Tim


1 Answers

From the documentation: https://developer.android.com/studio/write/vector-asset-studio.html

Strokes and fills Supported:

Strokes, including color, opacity, width, join, cap, dashes, and alignment. Solid color fills and strokes. Stroke and fill colors specified as RGB, Lab, or CMYK.

Conversion details:

If a stroke is dashed, clipped using a clipping base, or uses an alignment different from center, Vector Asset Studio converts it into a fill shape in the vector drawable.

So in short, Android Vector Drawables don't support dashed strokes yet.

You can import SVG files that contain dashed strokes but Vector Asset Studio will convert them to fill shapes.

like image 51
CanC Avatar answered Sep 17 '22 19:09

CanC