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"/>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With