virsir
virsir

Reputation: 15499

Custom gradient actionbar background, not display well, need dither

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?

Upvotes: 1

Views: 681

Answers (3)

Jose L Ugia
Jose L Ugia

Reputation: 6250

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.

Upvotes: 0

Roman Nurik
Roman Nurik

Reputation: 29745

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.

Upvotes: 2

vArDo
vArDo

Reputation: 4408

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.

Upvotes: 1

Related Questions