我正在Emulator Pixel 4,API 33中测试这一点.
我在drawable
文件夹中添加了一些drawable
xdrawable
的PNG图像,但它们都是模糊的.我把每一个都复制并粘贴到文件夹里.我试过android:src="drawable/..."
、android:background="drawable/..."
、android:scaleType="fitXY"
、android:adjustViewBounds="true"
和每一种的不同组合,但图像总是模糊.我甚至试过CircleImageView、Glide和毕加索,但模糊效果仍然存在.我的所有图像都会发生这种情况,但BottomNavigationView中的图像除外
以下是其中之一的一个例子:
这里是底部的导航视图,但不是那么模糊.我猜是因为它缩小了.
在iOS中,他们使用1x、2x、3x映像.我把上面的https://hotpot.ai/blog/ios-1x-2x-3x-generatorxhttps://hotpot.ai/blog/ios-1x-2x-3x-generator图像放到一个类似https://hotpot.ai/blog/ios-1x-2x-3x-generator的程序中,然后一旦我把图像拖到Assets文件夹中,我就不必担心模糊了(我有3个版本).在iOS中,同样的https://hotpot.ai/blog/ios-1x-2x-3x-generatorxhttps://hotpot.ai/blog/ios-1x-2x-3x-generator图像显示为sharp
问题是我复制并粘贴图像到Drawables文件夹,但我需要1x, 1.5x, 2x, 3x, and 4x
个版本的图像吗?顺便说一句,我还在学习Android.
示例代码:
<androidx.constraintlayout.widget.ConstraintLayout
<ImageView
android:layout_width="60dp"
android:layout_height="60dp"
android:src="drawable/profile_icon"
android:scaleType="fitXY"
android:adjustViewBounds="true"
.../>
<TextView
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="drawable/profile_icon"
android:scaleType="fitXY" // I've tried multiple scaleTypes
android:adjustViewBounds="true"
.../>
<TextView