Android:Dither="True" Does Not Dither, What's Wrong

Is it possible to dither a gradient drawable?

I wrote the documentation you referenced. I've taken another look at the code and unfortunately there's no way to enable dithering on a GradientDrawable except by explicitly calling GradientDrawable.setDither() in code.

(The way the codes looks, technically you could include the Gradient as the only child of a <selector>, and enable dithering on the entire selector; however, it's definitely a hack.)

I'm not convinced enabling dithering will actually solve your problem, as dithering (at least as it's noted in the official Android docs) are for solving banding problems when the device has too small of a color palette. This seems to be a banding problem due to the size of the gradient.

Android view dithering

From Android Developers: Widget Design Guidelines:

In some cases, devices have low pixel
depths that can cause visual banding
and dithering issues. To solve this,
application developers should pass
assets through a "proxy" drawable
defined as XML:. This technique
references the original artwork, in
this case "background.9.png", and
instructs the device to dither it as
needed.

EDIT:
Example source. This is an xml file in your res/drawables directory:

<?xml version="1.0" encoding="UTF-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/title_bar_medium"
android:dither="true" />

Bitmap appearance is not looking good, dithering is not working, in Android

I found the location where should I set the config. While creating the reflection bitmap set the config as ARGB_8888. Its working now.

Android gradient NEVER works (always banding)

Obviously it's just the emulator. On a real device it looks good.



Related Topics



Leave a reply



Submit