Android: Using linear gradient as background looks banded
As Romain Guy suggests:
listView.getBackground().setDither(true);
solves my problem
If this is not enough especially for AMOLED and/or hdpi devices try this:
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
Android gradient NEVER works (always banding)
Obviously it's just the emulator. On a real device it looks good.
Color banding and artifacts with gradients despite using RGBA_8888 everywhere
Just to wrap this up with an answer, the conclusion I have reached is that the Nexus 7 just has some hardware / firmware issue which means that it is utterly pants at rendering gradients.
Gradient Background that doesn't scale
- Use a RelativeLayout instead of a LinearLayout
- Instead of using your gradient as a background of the main container of the layout, add a child View, set the height explicitly to the size you want (230dp), and set the background of that view to your gradient.
Gradient appears banded in a SurfaceView, but looks very smooth in a normal View
Found the solution myself in the end by adding this into the SurfaceView
's constructor:
getHolder().setFormat(PixelFormat.RGBA_8888);
Related Topics
How to Find and Turn on Usb Debugging Mode on Nexus 4
How to Pause/Resume Thread in Android
Android Error - Open Failed Enoent
Android: How to Create a Dialog Without a Title
How to Get the Md5 Fingerprint from Java's Keytool, Not Only Sha-1
Missing "<Sdk>/Extras/Google/Google_Play_Services/Libproject" Folder After Update to Revision 30
How to Implement a View Holder
How to Programmatically Set the Layout_Align_Parent_Right Attribute of a Button in Relative Layout
How to Display Custom View in Actionbar
Open Failed: Eacces (Permission Denied)
How to Encrypt File from Sd Card Using Aes in Android
Google Android Usb Driver and Adb
How to Find Older Versions of Eclipse Adt
Org.JSON.JSON Exception:End of Input at Character 0
Android Hide/Unhide App Icon Programmatically