【问题标题】:Importing SVG gives error: `Attribute "android:fillType" was already specified for element "path".`导入 SVG 时出现错误:`已经为元素“路径”指定了属性“android:fillType”。`
【发布时间】:2019-11-20 13:40:55
【问题描述】:

以下是 SVG 文件内容。它是从 Figma(设计草图应用程序)导入的。

<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path fill-rule="evenodd" clip-rule="evenodd" d="M6.78759 8.20572L7.37223 7.62108C7.53367 7.45964 7.79542 7.45964 7.95686 7.62108L10.4589 10.1263C10.6203 10.2878 10.6203 10.5495 10.4589 10.711L9.87424 11.2956C9.71279 11.457 9.45104 11.457 9.2896 11.2956L6.78759 8.79036C6.62614 8.62892 6.62614 8.36717 6.78759 8.20572Z" fill="white"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M9.28759 5.70572L9.87223 5.12108C10.0337 4.95964 10.2954 4.95964 10.4569 5.12108L12.9589 7.62632C13.1203 7.78776 13.1203 8.04951 12.9589 8.21096L12.3742 8.7956C12.2128 8.95704 11.951 8.95704 11.7896 8.7956L9.28759 6.29036C9.12614 6.12892 9.12614 5.86717 9.28759 5.70572Z" fill="white"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M9.87424 9.54149L10.4589 10.1261C10.6203 10.2876 10.6203 10.5493 10.4589 10.7108L7.95686 13.2121C7.79542 13.3735 7.53367 13.3735 7.37223 13.2121L6.78759 12.6274C6.62614 12.466 6.62614 12.2042 6.78759 12.0428L9.2896 9.54149C9.45104 9.38005 9.71279 9.38005 9.87424 9.54149Z" fill="white"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M9.87424 5.70458L10.4589 6.28922C10.6203 6.45066 10.6203 6.71241 10.4589 6.87386L7.95686 9.37515C7.79542 9.53659 7.53367 9.53659 7.37223 9.37515L6.78759 8.79051C6.62614 8.62907 6.62614 8.36732 6.78759 8.20587L9.2896 5.70458C9.45104 5.54314 9.71279 5.54314 9.87424 5.70458Z" fill="white"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5 5.4165C13.1904 5.4165 13.75 4.85686 13.75 4.1665C13.75 3.47615 13.1904 2.9165 12.5 2.9165C11.8096 2.9165 11.25 3.47615 11.25 4.1665C11.25 4.85686 11.8096 5.4165 12.5 5.4165Z" fill="white"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M18.3332 13.3333C18.3332 11.4924 16.8408 10 14.9998 10C13.1589 10 11.6665 11.4924 11.6665 13.3333C11.6665 15.1743 13.1589 16.6667 14.9998 16.6667C16.8408 16.6667 18.3332 15.1743 18.3332 13.3333ZM13.3332 13.3333C13.3332 12.4129 14.0794 11.6667 14.9998 11.6667C15.9203 11.6667 16.6665 12.4129 16.6665 13.3333C16.6665 14.2538 15.9203 15 14.9998 15C14.0794 15 13.3332 14.2538 13.3332 13.3333Z" fill="white"/>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M8.33317 13.3333C8.33317 11.4924 6.84079 10 4.99984 10C3.15889 10 1.6665 11.4924 1.6665 13.3333C1.6665 15.1743 3.15889 16.6667 4.99984 16.6667C6.84079 16.6667 8.33317 15.1743 8.33317 13.3333ZM3.33317 13.3333C3.33317 12.4129 4.07936 11.6667 4.99984 11.6667C5.92031 11.6667 6.6665 12.4129 6.6665 13.3333C6.6665 14.2538 5.92031 15 4.99984 15C4.07936 15 3.33317 14.2538 3.33317 13.3333Z" fill="white"/>
</svg>

遇到的问题: Attribute "android:fillType" was already specified for element "path".

【问题讨论】:

    标签: android android-studio svg android-vectordrawable


    【解决方案1】:

    Android Studio 3.6 Beta 中有一个错误。请改用 Android Studio 3.5。

    【讨论】:

    【解决方案2】:

    转到drawable 文件夹并右键单击它:New &gt; Vector Asset &gt; select .svg file &gt; Next &gt; Finish。 它对我有用(骑自行车的人的照片)。

    如果您在使用ImageView 中的图像时遇到问题,请尝试从源svg 中删除fill-rule="evenodd"clip-rule="evenodd" 的属性并重新导入。

    【讨论】:

    • 这正是我正在做的,但它失败了。
    • 尝试将 svg 移动到不包含空格的路径。并尝试再次导入。
    【解决方案3】:

    删除“clip-rule”属性将解决 Android Studio 3.6 Canary 6 中引入但在早期版本中不存在的错误 (https://issuetracker.google.com/148173587)。

    “剪辑规则”属性在此上下文中无论如何都不起作用。 https://drafts.fxtf.org/css-masking-1/#the-clip-rule 说:“clip-rule 属性仅适用于包含在 clipPath 元素中的图形元素。”

    【讨论】:

      猜你喜欢
      • 2022-01-20
      • 2016-06-24
      • 2022-08-13
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      • 2012-03-13
      • 2018-10-29
      • 2020-04-05
      相关资源
      最近更新 更多