[英]Vector Asset Studio is importing colorful .svg file as black and white
I'm using the instructions found here, from Google<\/a> to use the new option (March 2016) to import .svg files into drawable instead of .png files.我正在使用
Google 提供的此处<\/a>的说明使用新选项(2016 年 3 月)将 .svg 文件导入 drawable 而不是 .png 文件。
Here's an image of the .svg file, as read by Google Chrome:这是 .svg 文件的图像,由 Google Chrome 读取:
<\/a>
This same file, is then read like this by the Vector Asset Studio: Vector Asset Studio 会像这样读取同一个文件:
<\/a>
<\/a>
And in the app, the image shows up as black and white.在应用程序中,图像显示为黑白。
Any idea of why this is happening?知道为什么会这样吗?
EDIT: added
link to .svg file I'm using<\/a> for this question.<\/strong>编辑:添加
了我用于此问题的 .svg 文件的链接<\/a>。<\/strong>
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.