尽管图像正确为白色,但图像并未显示完全白色

Bac*_*chi 5 rgb android colors

对于启动画面,我使用的图像包含白色背景(纯白色 - 在Photoshop中检查).出于某种原因,它显示了一个轻微的绿色bg与活动的默认白色bg - 如屏幕截图所示.只在某些设备上,比如

尽管图像使用白色,ImageView图形现在显示白色背景

我将此作为单一视图添加到活动的框架布局中:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scaleType="fitCenter"
    android:src="@drawable/splashscreen" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

任何的想法?我读到了RGB888与RGB565问题,但找不到合适的解决方案.

注意:我确定可以将图像中的白色更改为透明,但更愿意了解问题并找到合适的解决方案.

Axe*_*xel 9

这真的很烦人.我想知道,为什么很少有人遇到这个问题,因为它应该出现在所有32位显示器上.

你提到了关于RGB888格式的权利.问题的原因是,无论APK文件中的原始位图格式如何,所有位图都会被压缩(在我的情况下会变成索引的256色!wtf?).

我找不到阻止它的方法,所以如果有人知道正确的解决方案,请告诉我.

但是,我找到了两种白色问题的解决方案.

1)每位图:比如说,我们有一个可绘制的位图资源@drawable/mypng,它会导致问题.我们需要添加一个额外的XML drawable drawable/mypng_nofilter.xml

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/mypng"
    android:filter="false"
/>
Run Code Online (Sandbox Code Playgroud)

@drawable/mypng_nofilter改为使用.

2)对于整个活动:在我们需要添加的活动onCreate方法中

getWindow().setFormat(PixelFormat.RGB_565);
Run Code Online (Sandbox Code Playgroud)

现在窗口具有16位颜色深度,并且所有位图都显示为"正确"白色.

同样,我更喜欢32位颜色深度,但我不知道如何控制编译时图像压缩.