首页 > 解决方案 > 我收到消息 import SVG with ERROR@不支持

问题描述

Android Studio 向我发送消息"ERROR@ <feGaussianBlur> is not supported""ERROR@ <filter> is not supported"当我尝试将 SVG 导入 xml 时!

我使用 Inkscape 制作和编辑 SVG 文件。任何解决方案?

更新

安卓工作室 3.4.0

矢量 xml 代码:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="120dp"
    android:height="70dp"
    android:viewportWidth="120"
    android:viewportHeight="70">
  <path
      android:pathData="m29.87,5.114h81.925c2.212,0 3.312,1.83 2.467,4.104l-19.088,51.359c-0.845,2.274 -3.306,4.104 -5.518,4.104L7.731,64.681c-2.212,0 -3.312,-1.83 -2.467,-4.104L24.352,9.218c0.845,-2.274 3.306,-4.104 5.518,-4.104z"
      android:strokeWidth="0.43320084"
      android:fillColor="#000000"
      android:strokeColor="#00000000"
      android:fillAlpha="1"/>
  <path
      android:pathData="m29.87,4.585h81.925c2.212,0 3.312,1.83 2.467,4.104L95.174,60.048c-0.845,2.274 -3.306,4.104 -5.518,4.104L7.731,64.152c-2.212,0 -3.312,-1.83 -2.467,-4.104L24.352,8.689c0.845,-2.274 3.306,-4.104 5.518,-4.104z"
      android:strokeWidth="0.43320084"
      android:fillColor="#aaffaa"
      android:strokeColor="#00000000"/>
</vector>

错误信息:

错误@第 28 行:不支持

错误@第 36 行:不支持

标签: androidandroid-studiosvg

解决方案


<filter>并且feGuaussianBlur>是 SVG 过滤器元素。他们为 SVG 元素添加位图滤镜效果。

Android VectorDrawables不支持 SVG 过滤器

  • 如果您可以在没有滤镜效果(模糊)的情况下生活,请编辑您的 SVG 文件并删除它/它们。然后再次尝试导入。

  • 如果您需要模糊效果,那么您将无法使用 VectorDrawable。您将被迫改用位图图像。


推荐阅读