Android Vector中的虚线描边-dasharray [英] Dashes stroke-dasharray in Android Vector

查看:527
本文介绍了Android Vector中的虚线描边-dasharray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Android Vector Drawable上添加虚线?似乎Android Vector不支持svg的"stroke-dasharray". 还有其他方法吗? 我想绘制的可绘制对象:

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

推荐答案

来自文档: https://developer.android.com/studio/write/vector-asset -studio.html

笔划和填充支持:

Strokes and fills Supported:

笔触,包括颜色,不透明度,宽度,连接,上限,破折号和 结盟.纯色填充和描边.描边和填充颜色 指定为RGB,Lab或CMYK.

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.

转换详细信息:

如果笔划是虚线,使用剪切基进行剪切或使用与中心不同的路线,Vector Asset Studio 将其转换为矢量可绘制对象中的填充形状.

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.

因此,简而言之,Android Vector Drawables还不支持虚线.

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

您可以导入包含虚线的SVG文件,但是Vector Asset Studio会将其转换为填充形状.

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

这篇关于Android Vector中的虚线描边-dasharray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆