Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android studio AndroidStudio导入SVG时出错@<;面具>;不支持_Android Studio_Svg_Vector_Ide_Android Vectordrawable - Fatal编程技术网

Android studio AndroidStudio导入SVG时出错@<;面具>;不支持

Android studio AndroidStudio导入SVG时出错@<;面具>;不支持,android-studio,svg,vector,ide,android-vectordrawable,Android Studio,Svg,Vector,Ide,Android Vectordrawable,尝试使用导入SVG时,我收到消息“ERROR@不受支持” Android Studio 3.0.1 Build #AI-171.4443003, built on November 10, 2017 JRE: 1.8.0_152-release-915-b08 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Mac OS X 10.12.6 是否仍要导入SVG并使其正确显示?解决方案1 用于将SVG转换为Android的xml

尝试使用导入SVG时,我收到消息“ERROR@不受支持”

 Android Studio 3.0.1
Build #AI-171.4443003, built on November 10, 2017
JRE: 1.8.0_152-release-915-b08 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

是否仍要导入SVG并使其正确显示?

解决方案1

用于将SVG转换为Android的xml

解决方案2

我使用非零而不是偶数,并在草图中打开它以反转顺序,反转后它将更改pathData并删除android:fillType,并且在android 21+上一切正常

解决方案3

巴布亚新几内亚

TLDR

经过一些研究,我发现矢量图形有两种填充规则属性方法,SVG,“偶数奇”和“非零”

我在Sketch中打开了SVG图标,并检查了图标顶部的孔。正如预期的那样,它使用填充规则:evenodd属性。现在我必须更改填充规则以使用“非零”属性。怎么用?选择路径。在右侧,“填充”属性处有一个设置图标。单击它并选择“非零”

从主菜单中选择“图层”→ 路径→ 相反的顺序。我在图标顶部找到了一个洞,在应用程序中也找到了这个洞


如果您只有.svg文件,那么您可以手动操作.svg标记,以移除掩码并内联应用填充

如果你与设计师合作,你可以要求他们取下图标,移除遮罩内的任何东西,并对图标进行填充。然后让设计器导出.svg文件,然后重试导入到Android Studio中


当您尝试导入的资源从Sketch或其他设计器软件导出时,图标是一个掩码(与填充相反),它将与该标记一起导出。Android Studio只接受带有填充的.svg(这在iOS中不是问题)

在我的例子中,这是草图中符号覆盖的结果,草图是一种已知的技术,可以轻松更改符号的颜色。它要求在符号(嵌套符号)内使用(颜色)符号作为遮罩。这是导致问题的掩码

我的解决方案只是创建原始符号的导出版本,在其中删除掩码

  • 打开SVG文件并删除
    掩码
    元素。您可以保留
    use
    元素
  • 进口
  • 打开导入的文件
  • 删除最后一个具有
    fillType=“evenOdd”
  • 更新
    android:fillType=“nonZero”
    元素上的颜色
  • 当然,这取决于设计器导出资源的方式,但像这样编辑路径通常会使您到达所需的位置

    工具1)是变形器

    工具2)是

    在这个箱子上试试这个工具。 使用Android Vector Asset Studio时,您可能会遇到以下错误:

    Missing "viewBox" in <svg> element
    <animate> is not supported
    <animateColor> is not supported
    <animateMotion> is not supported
    <animateTransform> is not supported
    <mpath> is not supported
    <set> is not supported
    <a> is not supported
    <defs> is not supported
    <glyph> is not supported
    <marker> is not supported
    <mask> is not supported
    <missing-glyph> is not supported
    <pattern> is not supported
    <switch> is not supported
    <symbol> is not supported
    <feBlend> is not supported
    <feColorMatrix> is not supported
    <feComponentTransfer> is not supported
    <feComposite> is not supported
    <feConvolveMatrix> is not supported
    <feDiffuseLighting> is not supported
    <feDisplacementMap> is not supported
    <feFlood> is not supported
    <feFuncA> is not supported
    <feFuncB> is not supported
    <feFuncG> is not supported
    <feFuncR> is not supported
    <feGaussianBlur> is not supported
    <feImage> is not supported
    <feMerge> is not supported
    <feMergeNode> is not supported
    <feMorphology> is not supported
    <feOffset> is not supported
    <feSpecularLighting> is not supported
    <feTile> is not supported
    <feTurbulence> is not supported
    <font> is not supported
    <font-face> is not supported
    <font-face-format> is not supported
    <font-face-name> is not supported
    <font-face-src> is not supported
    <font-face-uri> is not supported
    <hkern> is not supported
    <vkern> is not supported
    <linearGradient> is not supported
    <radialGradient> is not supported
    <stop> is not supported
    <ellipse> is not supported
    <polyline> is not supported
    <text> is not supported
    <use> is not supported
    <feDistantLight> is not supported
    <fePointLight> is not supported
    <feSpotLight> is not supported
    <altGlyph> is not supported
    <altGlyphDef> is not supported
    <altGlyphItem> is not supported
    <glyphRef> is not supported
    <textPath> is not supported
    <tref> is not supported
    <tspan> is not supported
    <clipPath> is not supported
    <color-profile> is not supported
    <cursor> is not supported
    <filter> is not supported
    <foreignObject> is not supported
    <script> is not supported
    <view> is not supported
    
    元素中缺少“viewBox”
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    不支持
    
    删除遮罩元素和遮罩属性?解决方案2的链接在哪里?我要求设计师使用草图来美化图像,有时它的workLink会被弃用,并将您带到studio工具,因此这不再是解决方案。几乎是,但元素是圆形的,最后是方形的