我使用了几张图片,通过Android Studio的矢量图标工具导入本地SVG文件。这些图片在我的Nexus 6P上加载得很好,但是在Sony Xperia Z上非常模糊,在Samsung Galaxy S2上更糟糕。
我理解的是,由于文件是XML(向量),而不是PNG文件,它应该能够自动调整大小,或者我忽略了什么。
我附上了3种情况的图片。
编辑:只是一些额外的信息:该文件最初是PNG格式,但是我使用了一个叫Vector Magic的程序将其完全转换为向量文件。我可以在Illustrator中打开并编辑每条线等。
通过使用VectorDrawableCompat.create(...)方法从VectorDrawable更改为VectorDrawableCompat来解决问题。谢谢@pskink。
VectorDrawable
还是BitmapDrawable
:使用Log.d
记录View#getBackground
或ImageView#getDrawable
的值(我不知道你在哪里使用你的图像)。 - pskinkVectorDrawable
存在问题,所以请使用VectorDrawableCompat
。 - pskink