Image does not appear completely white even though it is correctly white

For a splash screen, I use an image that contains a white background (pure white - checked in Photoshop). For some reason, it shows a small green bg compared to the default active white bg - as noted in the screenshot. Only on some devices, such as

ImageView graphic shows now white background despite the image uses white

I add this as a separate view in the frame layout to the activity:

<?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>

Any idea? I read about problems with RGB888 and RGB565, but could not find the right solution.

Note. I am sure that you can make the white change in the image transparent, but they prefer to understand the problem and find the right solution.

+5
source share
5 answers

. , , 32- .

RGB888. , APK ( 256-! Wtf?).

, , - , , .

.

1) Per-bitmap: , , @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"
/>

@drawable/mypng_nofilter.

2) : onCreate

getWindow().setFormat(PixelFormat.RGB_565);

16- , "" .

, 32- , , .

+9

, Bitmap.CompressFormat PNG JPEG:

Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.nouv);
Bitmap bitmap = (Bitmap)((BitmapDrawable) drawable).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
+2

. , -. ICS , ICS. , ( ImageView.)

BitmapDrawable bitmapDrawable = new BitmapDrawable(imageView.getContext().getResources(), bitmap);
bitmapDrawable.setFilterBitmap(false);
imageView.setImageDrawable(bitmapDrawable);
0

, :

android:scaleType="centerCrop"

, ...

-1

You can also define the background for your FrameLayout or your ImageView using the color of your image (which seems F8FCF8):

Android: background = "# F8FCF8"

-1
source

All Articles