我想在 android 上显示一个 png 图像。这是图像文件:
右端比左端暗一点。
但是在 android 应用程序(使用 ImageView)上图像质量丢失了:
请注意红框部分。颜色变化不流畅。
但是如果我用安卓手机的浏览器,播放效果很好(所以不是手机屏幕的原因):
这是我的android代码,非常简单:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/hhh"/>
</LinearLayout>
hhh
是我在这里发布的第一张图片,位于 res/drawable
下。
我在我的安卓手机(安卓2.3.6)和安卓模拟器(安卓2.2/2.3/4.0)上测试过,都显示不正常。但它在我的 android pad (android 4.0.3) 上运行良好。
问题是什么,如何解决?
最佳答案
res/drawable
中的图像被压缩。 This is supposed to be lossless ,但我过去听说过类似的问题。
将它移到 res/raw
中,然后试一试。
关于android - 为什么 android 在显示 png 文件时会丢失图像质量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13137735/