【发布时间】:2016-09-13 06:03:55
【问题描述】:
我使用了几个图像,这些图像是使用 Android Studio 的 Vector Asset Studio 通过本地 SVG 文件导入的。
图像在我的 nexus 6p 上完美加载,然而,在索尼 Xperia Z 上,它非常像素化,在三星 Galaxy s2 上,它更糟糕。
据我了解,由于该文件是 xml(矢量)而不是 png 文件,它应该能够自动调整大小,或者我错过了什么。
编辑:只是一些额外的信息:该文件最初是 PNG,但是,我已经使用名为 Vector Magic 的程序完全转换为矢量文件。我可以在 illustrator 上打开它并编辑每一行等。
解决方法通过 VectorDrawableCompat.create(..) 方法将 VectorDrawable 更改为 VectorDrawableCompat。谢谢@pskink。
【问题讨论】:
-
而且...是的,已确认。该工具从原始 SVG 文件生成位图:
Android 4.4 (API level 20) and lower doesn't support vector drawables. If your minimum API level is set at one of these API levels, you have two options when using Vector Asset Studio: generate Portable Network Graphic (PNG) files (the default) or use the Support Library. For backward-compatibility, Vector Asset Studio generates raster images of the vector drawable供您参考:developer.android.com/studio/write/vector-asset-studio.html。 -
检查this是否有帮助
-
@BobMalooga 感谢您的链接,非常有用。但是,xperia Z 是在 Android 5.0.2 上,所以它应该支持矢量绘图,因此不应该是模糊的。
-
是的,它支持... VectorDrawables。但是如果你给它Bitmaps,它就会使用Bitmaps。
-
所以使用
VectorDrawableCompat因为VectorDrawable在v5 设备上已损坏
标签: android xml svg vector android-drawable