Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change RadialGradient, gradient position?

Here is an image of what I need:

https://i.sstatic.net/y4XPe.jpg I need to go from 1 to 2 and it has to be one programatically no xml.

//Create transparent circle
RadialGradient gradient = new android.graphics.RadialGradient(newBitmap.getWidth() /     2,newBitmap.getHeight() / 2, newBitmap.getWidth() - newBitmap.getWidth() / 2, 0x00000000, 0xFF000000, android.graphics.Shader.TileMode.CLAMP);
like image 674
Oliver Dixon Avatar asked Jan 27 '26 18:01

Oliver Dixon


1 Answers

Figured this out,

//Create transparent circle
    int[] Colors = {0x00000000, 0xFF000000};
    float[] ColorPosition = {0.60f, 0.99f};
    RadialGradient gradient = new android.graphics.RadialGradient(newBitmap.getWidth() / 2,newBitmap.getHeight() / 2, newBitmap.getWidth() - newBitmap.getWidth() /2, Colors, ColorPosition, android.graphics.Shader.TileMode.CLAMP);

Where the colour positions are the percentage positions of the colours above (Can have many as you want)

like image 140
Oliver Dixon Avatar answered Jan 30 '26 08:01

Oliver Dixon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!