SweepGradient and Banding

by Shane » Fri, 26 Feb 2010 01:52:40 GMT

Sponsored Links

I'm writing an android app to that among other things lets a user
choose a color using a color wheel that is drawn using a SweepGradient
shader.  The shader is set up as follows:

        mColors = new int[] { Color.RED, Color.MAGENTA, Color.BLUE,
Color.CYAN, Color.GREEN,  Color.YELLOW, Color.RED };
        Shader s = new SweepGradient(0, 0, mColors, null);

I assign that shader to a Paint object which I then use inside of a
onDraw callback in a custom view to an oval using the paint/shader
object.  Here's the problem...

If I use that view inside of a Dialog and display the Dialog the oval
displays great, all colors in the gradient seamlessly blend together.
However, if I use that same view on its own the same SweepGradient
looks banded especially between green->red, magenta->blue, blue-
changing dither makes no difference.  I'm at a loss as to what to try,
I'm hoping someone has some clues on this.

Oh and BTW, this same behavior happens in the emulator or running on
my Motorola Droid.



SweepGradient and Banding

by Gaunt Face » Sat, 27 Feb 2010 05:37:31 GMT

 Heya Shane,

I've had a similar problem with gradients applied to backgrounds, what
I found the issue was, was I had didn't have the drawables in the
correct dpi folder.

While I know your not using a drawable it might be worth looking into
whether changing the AndroidManifest file to state your app handles
different screen sizes.

I don't know if this is the problem, especially considering the dialog
view working, but it might be worth a try:

// Add just underneath the Manifest tag

          android:anyDensity="true" />


Sponsored Links

Other Threads

1. Update : Droid X harga spesial (Booked)

Mau update status WTS semalam,

Droid X sudah ada yg booked yah, considered sold.

Lelang Evo masih dibuka s.d pukul 23 nanti, setelah ditutup nanti akan
diumumkan peserta beserta harga penawarannya, supaya fair.
Sudah ada 2 penawar. Ayo bid, spy yakin menang.


2. Android SDK for Android

Is it possible to run a android sdk on android itself? Ie. develop and
maintain software only using a android device?


3. Accessing Video Thumbnail

4. spica froyo kitchen... alpha...

5. Streaming di android

6. Facebook Publish Error In Anroid Application

7. when i connect facebook through android after sign in ....