我有一个ConstraintLayout
,可以使用scaleX
和scaleY
进行缩放,这在大多数设备上都可以正常使用,但是我注意到{ {1}}在某些手机(运行Android 9的OnePlus)上看起来非常像素化。
具有FHD分辨率的三星Galaxy S10,Android 9:
具有WHQL分辨率的三星Galaxy S10,Android 9:
ImageViews
使用矢量可绘制,并且我们设置了以下内容:
ConstraintLayout
ImageView
但是,某些手机(OnePlus)上的图像仍然像素化
有什么想法吗?
修改
这是可绘制对象:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
这是vectorDrawables.useSupportLibrary = true
:
<vector
android:height="24dp"
android:viewportHeight="52"
android:viewportWidth="52"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#00394D" android:fillType="evenOdd"
android:pathData="M1.0024,26.342C0.8134,12.559 11.873,1.1907 25.6569,1.0018L26.0037,1C39.5995,1 50.8108,12.0613 50.9971,25.658C51.186,39.441 40.1256,50.8093 26.3417,50.9973L25.994,51C12.399,51 1.1878,39.9387 1.0024,26.342ZM25.7394,7.0155C20.6766,7.0856 15.9386,9.1268 12.3982,12.7657C8.8577,16.4046 6.946,21.1976 7.0152,26.2604C7.1562,36.5854 15.6707,44.9863 25.9957,44.9863L26.2592,44.9845C36.7271,44.8408 45.1271,36.2075 44.9843,25.7396C44.8423,15.4146 36.3279,7.0137 26.0037,7.0137L25.7394,7.0155Z"
android:strokeColor="#00000000" android:strokeWidth="1"/>
<path android:fillColor="#009DDB" android:fillType="evenOdd"
android:pathData="M26.3287,12.2772C24.6911,12.2772 23.3593,13.6099 23.3593,15.2476L23.3593,28.2101C23.3593,28.4019 23.3795,28.5973 23.4171,28.791L23.4706,28.9811L23.5135,29.1222L23.5862,29.3456C23.6213,29.4297 23.6642,29.5086 23.7089,29.5857L23.7737,29.7048L23.8579,29.8564C23.97,30.0238 24.0962,30.1771 24.232,30.3129L29.5645,35.6464C30.1253,36.208 30.871,36.5164 31.6648,36.5164C32.4586,36.5164 33.2043,36.208 33.765,35.6464C34.9225,34.4889 34.9225,32.6042 33.765,31.4467L29.2982,26.9807L29.2982,15.2476C29.2982,13.6099 27.9664,12.2772 26.3287,12.2772"
android:strokeColor="#00000000" android:strokeWidth="1"/>
</vector>
答案 0 :(得分:0)
您可以将android:scaleType="fitXY"
添加到ImageView
它可能会解决您的问题
并确保您的向量不包含像.2或.4这样的十进制值,它应像0.2和0.4一样,您可以从代码检查器中对其进行分析
任何人甚至都可以在设置24dp时更改矢量的宽度和高度,因为默认情况下,您可以尝试这样做,这可能会有所帮助
<vector android:height="80dp" android:width="80dp"
类似这样