Oliver Dixon
Oliver Dixon

Reputation: 7405

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

Upvotes: 3

Views: 1015

Answers (1)

Oliver Dixon
Oliver Dixon

Reputation: 7405

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)

Upvotes: 4

Related Questions