Dashes stroke-dasharray in Android Vector

落爺英雄遲暮 提交于 2020-01-14 14:55:13

问题


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"/>


回答1:


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.



来源:https://stackoverflow.com/questions/45893855/dashes-stroke-dasharray-in-android-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!