Custom gradient actionbar background, not display well, need dither

682 views Asked by At

I use a linear background (xml shape) as the actionbar background in android 4.0. It does not display well, looks banded.

How to make it render smooth?

3

There are 3 answers

0
vArDo On

Try increasing PixelFormat quality of a window:

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();
    getWindow().setFormat(PixelFormat.RGBA_8888);
}

This is possibly a duplicate of this question.

0
Roman Nurik On

First, I'm assuming you're using the default RGBA_8888 pixel format (default as of Android 2.3). Second, on some displays gradients render poorly. One workaround is to overlay a small bit of noise over the gradient (a repeating semi-transparent noise texture in drawable-nodpi should do) using a <layer-list> drawable.

0
Jose L Ugia On

Is it a repeating pattern (tiled) or a nine patch? ICS is having some issues with certain types of rendering since it is by default drawing using hardware acceleration which makes it impossible to use some drawing techniques (specially when Drawables) and generates undesired results with some others. You can see some explanation and a list here.

Fortunately there are solutions or workarounds to most of them. Just need to know which exact kind of element are you using to draw your background.