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
Yuv to Rgb Conversion by Fragment Shader
Android: Drawing Custom Shapes
Android Gcm (Push Notification): Device Doesn't Receive Notification If Application Is Stopped
How to Know If a Fragment Is Visible
How to Use Default Android Drawables
Start Google Hangout from Intent in New Hangouts Android App
How to Detect Bottom Soft Navigation Bar Available in Android Programmatically
Query the Google Play Store for the Version of an App
Taking a "Screenshot" of a Specific Layout in Android
How to Close the Status Bar/Notification Panel After Notification Button Click
Why Is Calling Process.Killprocess(Process.Mypid()) a Bad Idea
Android Audiotrack Playing .Wav File, Getting Only White Noise
Flutter - How to Pass Custom Arguments in Firebase Dynamic Links for App Invite Feature
Retrofit2: Modifying Request Body in Okhttp Interceptor
Saving Arraylists in SQLite Databases
How to Return String or JSONobject from Asynchronous Callback Using Retrofit