VectorDrawable图像变为像素化 [英] VectorDrawable image becomes pixelated

查看:102
本文介绍了VectorDrawable图像变为像素化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一些图像,这些图像是使用Android Studio的Vector Asset Studio通过本地SVG文件导入的.

I've used a couple of images which I've imported using Android Studio's Vector Asset Studio through a local SVG file.

图像在我的nexus 6p上完美加载,但是在像素非常高的Sony Xperia Z和三星Galaxy s2上完美加载.

The images loaded perfectly on my nexus 6p, however, on the Sony Xperia Z, its very pixelated, and on Samsung Galaxy s2, its even worse.

据我了解,由于该文件是xml(矢量)而不是png文件,因此它应该能够自动调整大小,或者我错过了某些内容.

From my understanding, since the file is a xml (vector) and not a png file, it should have been able to resize automatically or am I missing out on something.

我已附上3个案例的图片.

I've attached an image of the 3 cases.

仅提供一些额外信息:该文件原本是PNG,但是我已经使用名为Vector Magic的程序将其完全转换为矢量文件.我可以在illustrator上打开它并编辑每行等.

Just some extra info: The file was originally a PNG, however, I've fully converted to an vector file using a program called Vector Magic. I can open it on illustrator and edit each line etc.

解决方案,通过VectorDrawableCompat.create(..)方法从VectorDrawable更改为VectorDrawableCompat.谢谢@pskink.

Solved by changing from VectorDrawable to VectorDrawableCompat through the VectorDrawableCompat.create(..) method. Thanks @pskink.

推荐答案

在图像中添加android:scaleType="fitXY"可以为我解决.

Adding android:scaleType="fitXY" to the image solved it for me.

这篇关于VectorDrawable图像变为像素化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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