Reputation: 5254
The reader can refer to this question: android:dither="true" does not dither, what's wrong?
I had color banding too... The solution was to create an alias (in xml) with dither set to "true" for my png images with gradients. This worked until I specified the SDK version in my manifest file <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
...
Color banding reappeared on emulator with Android 1.6 (API level 4) and skin WVGA800
Does somebody can explain me why !?
Project files: https://rapidshare.com/files/3429393846/Dithering.zip
--
My layout and the target to its background (alias with dithering):
<?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"
android:background="@drawable/d_gradient_grey_dither">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
The background (d_gradient_grey_dither.xml):
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/d_gradient_grey"
android:antialias="true"
android:dither="true"/>
The manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" />
</manifest>
See the result here:
And the project files if it can help:
https://docs.google.com/leaf?id=0B6Y0F7DEUPbPZTM5MDU0YzAtNjJiYi00NTU0LTlmNTAtMWJiZTJhNjBhYjA3&hl=fr
or (zipped)
https://rapidshare.com/files/3429393846/Dithering.zip
Upvotes: 3
Views: 982
Reputation:
This is what I use and I have used thru API 11.
/** -- Eliminates color banding -- **/
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
Upvotes: 3