0

the background I am using for my android application looks like this:

original background image

But now when loading it into my surfaceview:

canvas.drawBitmap(background, 0, 0, null);

The result looks like this:

screenshot

Note that smooth gradient is gone!!

How should i proceed to recieve a background like the first image i uploaded?

Thanks in advance

user2410644
  • 3,861
  • 6
  • 39
  • 59

1 Answers1

0

This is known as banding and is a common problem. hardware accelerated devices can handle gradients better than non accelerated devices. I suggest you do something like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_accelerated="true" android:drawable="@drawable/background_grad" />
    <item android:state_accelerated="false" android:drawable="@drawable/background_no_grad" />
</selector>

Other suggestions such as changing the dither never worked for me. But I'll link you to one here.

Community
  • 1
  • 1
whizzle
  • 2,053
  • 17
  • 21