android - 将 VectorDrawable 转换为 SVG

标签 android svg android-vectordrawable

我已经手动或使用网络工具进行了相反的转换(SVG 到 VectorDrawable)。

但我很难做相反的事情。我有 VectorDrawable 但我不知道如何将其转换为 SVG,我可以找到零个在线工具来做到这一点。

有没有人有这方面的经验,有哪些步骤或工具可以做到这一点?

最佳答案

我遵循的步骤:

android:pathData 替换为 d

android:fillColor 替换为 fill

android:strokeColor 替换为 stroke

android:strokeWidth 替换为 stroke-width

android:fillType 替换为 fill-rule

VectorDrawable 中没有 fillColor 的路径是 SVG 中的 fill="none"

android:viewportHeight="24"android:viewportWidth="24" 在 SVG 中是 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>

关于android - 将 VectorDrawable 转换为 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44948396/

相关文章:

java - 压缩机是抽象的;无法实例化

java - Android/Java - 暂停线程

android studio SVG 文件导入出现错误@第 8 行 : Unsupported color format "rgba(0,0,0,0)"

java - 如何以编程方式设置 Vector Drawable 的组参数?

java - 方向更改后按钮和菜单停止工作

android - 从 Eclipse 迁移到 Android Studio : Attribute has already been defined

javascript - 如何在 IE 11 的 Image.load 上获取 SVG 的宽度和高度

javascript - 如何制作类似维基百科和 Facebook 的悬停效果

html - 可以将 SVG 剪辑路径相对于其容器居中吗?

android - SVG 资源的正确可绘制文件夹