VectorDrawable在手机中的渲染方式与Android Studio中的渲染方式不同 [英] VectorDrawable renders differently in phone than in Android Studio

查看:71
本文介绍了VectorDrawable在手机中的渲染方式与Android Studio中的渲染方式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些样式化的文本,已将其转换为SVG路径,以供在VectorDrawable中使用.我直接从.svg文件中提取了路径数据作为文本字符串,以用作VectorDrawable中的路径数据.在Android Studio设计窗口中,它们看起来非常完美,但是当我在手机上运行它时,看起来很混乱.我的手机是HTC One M8,正在运行棉花糖.我已经附上了两个截屏,说明它们之间的区别.

I have some stylized text that I have converted into SVG paths for use in a VectorDrawable. I directly extracted the path data as a string of text from the .svg file to use as the path data in the VectorDrawable. They look perfectly fine in the Android Studio design window but when I run it on my phone it looks messed up. My phone is a HTC One M8 and is running stock Marshmallow. I have attached two screen shots of how they differ.

pathData:

vs. pathData在手机上呈现:

vs. pathData rendered on phone:

这是XML文件中的path资源

Here is the path resource from the XML file

<path
    android:name="anger_word"
    android:fillColor="#FFFFFF"
    android:pathData="@string/anger_word" />

这是实际的pathData,它是@string/anger_word http://pastebin.com/7MDLiwQh

这是怎么回事?

谢谢.

推荐答案

现在可能已修复,但某些VectorDrawable呈现代码的初始版本存在一些解析路径数据的错误. IIRC,尤其是相对路径命令.相对路径命令是带有小写字母的命令.相对路径命令似乎是路径中大多数命令.

It may have been fixed now, but some initial versions of the VectorDrawable rendering code had some bugs parsing path data. IIRC especially with relative path commands. Relative path commands are the ones with lower case letters. Relative path commands seem to be the majority of the the commands in your path(s).

我的建议是尝试将路径转换为仅使用绝对路径命令(大写字母).这可能不是问题,但是可以尝试.

My advice would be to try converting the paths to use absolute path commands only (upper case letters). This may not be the problem, but it is something to try.

我不知道您使用什么编辑器来创建路径,但请查看是否可以使用绝对路径命令将其输出到路径.

I don't know what editor you used to create your paths, but see if you can get it to output paths with absolute path commands.

如果不能,则可以搜索工具来实现.我相信Inkscape会做到的.请参阅以下问题的讨论.请注意,它主要是在讨论与所需转换相反的转换.

If it can't, then you can search for a tool to do it. I believe Inkscape will do it. See the discussion in the following question. Note that it is primarily discussing the opposite conversion to what you need.

是否存在将SVG线路径从绝对转换为相对的工具?

这个问题也可能有帮助.

Also this question may be of help too.

将SVG路径转换为绝对命令

这篇关于VectorDrawable在手机中的渲染方式与Android Studio中的渲染方式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆