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).