简体   繁体   English

Vector Asset Studio 正在将彩色 .svg 文件导入为黑白

[英]Vector Asset Studio is importing colorful .svg file as black and white

I also had the same problem but after digging internet finally found the solution, here it is:- 我也有同样的问题,但在挖掘互联网后终于找到了解决方案,这里是: -

After getting done with illustrator designing 完成插画设计后

1) Go to File --> Save As ---> Window Dialog box Opens--> type name of svg --->Click Save 1)转到文件 - >另存为--->窗口对话框打开 - >键入svg名称--->单击保存

2) Now it shows SVG Options dialog box ---> At bottom left click More Options ---> In CSS Properties dropdown ---> Select Presentation Attributes 2) 现在它显示SVG选项对话框--->在左下角单击更多选项--->在CSS属性下拉菜单--->选择显示属性

this setting makes svg compatible code for android import with colors !! 此设置使svg兼容代码为Android导入颜色!!

Sorry for making this answer elaborate ... did this for those who are beginners 很抱歉让这个答案详细说明......为初学者做了这个

Android Studio's SVG importer is somewhat limited. Android Studio的SVG导入程序有限。 It only handles very simple SVG files. 它只处理非常简单的SVG文件。 And I don't believe it supports the <style> element, or the class attribute. 我不相信它支持<style>元素或class属性。 So you will need to change the CSS to XML properties. 因此,您需要将CSS更改为XML属性。

For example: 例如:

<path class="st0" d="M163.3,10.8c2.4-0.5,6.2-0.9,10-0.9c5.5,0,9,0.9,11.6,3.1c2.2,1.6,3.5,4.1,3.5,7.5c0,4.1-2.7,7.7-7.2,9.3v0.1
    c4,1,8.7,4.3,8.7,10.6c0,3.6-1.4,6.4-3.6,8.5c-3,2.7-7.7,4-14.6,4c-3.8,0-6.7-0.3-8.5-0.5V10.8z M168.8,28.1h5c5.8,0,9.2-3,9.2-7.1
    c0-5-3.8-6.9-9.3-6.9c-2.5,0-4,0.2-4.8,0.4V28.1z M168.8,48.4c1.1,0.2,2.6,0.3,4.6,0.3c5.7,0,10.9-2.1,10.9-8.2
    c0-5.8-5-8.2-10.9-8.2h-4.5V48.4z"/>

Will need to be changed to: 需要改为:

<path fill="#007299" d="M163.3,10.8c2.4-0.5,6.2-0.9,10-0.9c5.5,0,9,0.9,11.6,3.1c2.2,1.6,3.5,4.1,3.5,7.5c0,4.1-2.7,7.7-7.2,9.3v0.1
    c4,1,8.7,4.3,8.7,10.6c0,3.6-1.4,6.4-3.6,8.5c-3,2.7-7.7,4-14.6,4c-3.8,0-6.7-0.3-8.5-0.5V10.8z M168.8,28.1h5c5.8,0,9.2-3,9.2-7.1
    c0-5-3.8-6.9-9.3-6.9c-2.5,0-4,0.2-4.8,0.4V28.1z M168.8,48.4c1.1,0.2,2.6,0.3,4.6,0.3c5.7,0,10.9-2.1,10.9-8.2
    c0-5.8-5-8.2-10.9-8.2h-4.5V48.4z"/>

Etcetera for the rest of the <path> elements. Etcetera用于<path>元素的其余部分。

It's so simple you can change your color directly from your svg xml after adding image to your project .非常简单,您可以在将图像添加到项目后直接从 svg xml 更改颜色。

when you added image to your project;当您将图像添加到项目时; svg color must be like this : svg 颜色必须是这样的:

android:fillColor="#000000"

just need to change to this :只需要更改为:

android:fillColor="#b3ff856d"

just looking for android:fillColor只是在寻找 android:fillColor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在资产导入时 SVG 文件中的文本属性没有出现在 Android Studio 矢量资产 XML 中 - Why text attribute in SVG file does not appear in Android Studio vector asset XML on asset import 将矢量资源导入 Android Studio 时出错 - Error importing Vector Asset into Android Studio 在 Android Studio 中导入矢量资源时无法解析符号 - Cannot Resolve Symbol when importing vector asset in Android Studio Android Vector Asset Studio:导入 SVG 并使用 ID 作为名称 - Android Vector Asset Studio: Import SVG and use ID as Name 为什么我的 SVG 无法在 Vector Asset Studio 中加载 - Why is my SVG failing to load in Vector Asset Studio 使用PDF或Vector文件在Android Studio中添加所有大小的图像资产 - Add all sizes of image asset in Android Studio with a PDF or Vector file 如何在 Android Studio 中查看自定义矢量资源(由 SVG 格式添加)的预览? - How to see a preview of custom vector asset (added by SVG format) in Android Studio? 如何着色装载SkiaSharp的黑白SVG? - How to colorize black and white SVG loaded with SkiaSharp? 导入Vector Asset后,Gradle构建错误 - Gradle build error after importing Vector Asset 如何将SVG转换为Android的矢量资产 - How to convert svg to vector asset for android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM