将VectorDrawable转换为SVG [英] Convert VectorDrawable to SVG
问题描述
我手动或使用Web工具进行了相反的转换(从SVG到VectorDrawable
).
I have made the opposite conversions (SVG to VectorDrawable
) manually or using web tools.
但是我很难做相反的事情.我有VectorDrawable
,但是我不确定如何将其转换为SVG,我可以找到零在线工具来实现.
But I am having hard time to do the opposite thing. I have VectorDrawable
but I am not sure how to convert it to SVG and I can find zero online tools to do it.
有人有经验吗?有哪些步骤或工具?
Does anyone have experience with this and what are the steps or tools to do it?
推荐答案
我遵循的步骤:
android:pathData
替换为d
android:fillColor
替换为fill
android:strokeColor
替换为stroke
android:strokeWidth
替换为stroke-width
android:fillType
替换为fill-rule
在SVG中,不带fillColor
的VectorDrawable中的路径为fill="none"
.
A path in the VectorDrawable without fillColor
is fill="none"
in SVG.
android:viewportHeight="24" android:viewportWidth="24"
是viewBox="0 0 24 24"
.
示例
可绘制矢量
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#ffffff"
android:pathData="M12,3L2,12h3v8h2.5v-0.8c0-1.5,3-2.2,4.5-2.2s4.5,0.8,4.5,2.2V20H19v-8h3L12,3zM12,15.2c1.2,0-2.2-1-2.2-2.2 s1-2.2,2.2-2.2s2.2,1,2.2,2.2S13.2,15.2,12,15.2z" />
<path android:pathData="M0,0h24v24H0V0z" />
</vector>
SVG
<svg xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24" >
<path
fill="#ffffff"
d="M12,3L2,12h3v8h2.5v-0.8c0-1.5,3-2.2,4.5-2.2s4.5,0.8,4.5,2.2V20H19v8h3L12,3zM12,15.2c1.2,0-2.2-1-2.2-2.2 s1-2.2,2.2-2.2s2.2,1,2.2,2.2S13.2,15.2,12,15.2z" />
<path d="M0,0h24v24H0V0z" fill="none"/>
</svg>
这篇关于将VectorDrawable转换为SVG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!