1

I have already set window.setFormat(PixelFormat.RGBA_8888) in onCreate and onAttachedToWindow in my activity. Still the background in the below shape is color banded.

setDither(true) that I found in other posts is deprecated and ignored.

The parameters of GradientDrawable's instance are:

  colors = intArrayOf(firstColor, secondColor)
  orientation = GradientDrawable.Orientation.LEFT_RIGHT
  gradientType = GradientDrawable.LINEAR_GRADIENT
  shape = GradientDrawable.RECTANGLE

Edit: I'm guessing there aren't enough colors for the shades I use. How do I know beforehand that they won't be enough? (As the shape could be displayed on a higher resolution display).

rtsketo
  • 1,168
  • 11
  • 18
  • Maybe try this? https://stackoverflow.com/a/67162224/506796 I think the reason `setDither` is deprecated is because dithering was only ever used with `565` color, so when that was retired there is no reason to use the setting any more. – Tenfour04 Jul 12 '21 at 12:32
  • I've tried that as well. It just changed a bit the pattern of the banding. – rtsketo Jul 12 '21 at 12:51
  • Personally, I never figured this out and ended up in my case creating a PNG image with dithering in Inkscape and using that. – Tenfour04 Jul 12 '21 at 12:56

0 Answers0