Blurry Image on API 21+ : AppCompat v23.2.0 using VectorDrawables with srcCompat

与世无争的帅哥 提交于 2019-12-04 10:25:55

This is to do with the scaleType in your ImageView which does inconsistent things at these different API levels when it comes to VectorDrawables.

There is one scaleType which seems to consistently give a sharp image when scaling: android:scaleType="fitXY" but when using this you have to ensure that the ImageView has the same aspect ratio as the Vector Drawable (eg. if you use fitXY with a square VectorDrawable and a rectangular ImageView it will stretch the image out).

Alternatively you can change the size in the VectorDrawable itself by setting

<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="225dp"
android:height="225dp"
.../>

By doing this there will be no scaling necessary in the ImageView.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!