Android: Using Linear Gradient as Background Looks Banded

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

  1. Use a RelativeLayout instead of a LinearLayout
  2. 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



Leave a reply



Submit