# RadialGradient

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/graphics/RadialGradient#pubctors)\|[Inherited Methods](https://developer.android.com/reference/android/graphics/RadialGradient#inhmethods)  

# RadialGradient

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/graphics/RadialGradient "View this page in Kotlin")\|Java

`
public


class
RadialGradient
`  
`


``

extends `[Shader](https://developer.android.com/reference/android/graphics/Shader)`


``


`

|---|---|---------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.graphics.Shader](https://developer.android.com/reference/android/graphics/Shader) ||
|   | ↳ | android.graphics.RadialGradient |

<br />

*** ** * ** ***

## Summary

|                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                             ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[RadialGradient](https://developer.android.com/reference/android/graphics/RadialGradient#RadialGradient(float,%20float,%20float,%20float,%20float,%20float,%20long[],%20float[],%20android.graphics.Shader.TileMode))`(float startX, float startY, float startRadius, float endX, float endY, float endRadius, long[] colors, float[] stops, `[Shader.TileMode](https://developer.android.com/reference/android/graphics/Shader.TileMode)` tileMode) ` Create a shader that draws a radial gradient given the start and end points as well as starting and ending radii. |
| ` `[RadialGradient](https://developer.android.com/reference/android/graphics/RadialGradient#RadialGradient(float,%20float,%20float,%20int,%20int,%20android.graphics.Shader.TileMode))`(float centerX, float centerY, float radius, int centerColor, int edgeColor, `[Shader.TileMode](https://developer.android.com/reference/android/graphics/Shader.TileMode)` tileMode) ` Create a shader that draws a radial gradient given the center and radius.                                                                                                                     |
| ` `[RadialGradient](https://developer.android.com/reference/android/graphics/RadialGradient#RadialGradient(float,%20float,%20float,%20int[],%20float[],%20android.graphics.Shader.TileMode))`(float centerX, float centerY, float radius, int[] colors, float[] stops, `[Shader.TileMode](https://developer.android.com/reference/android/graphics/Shader.TileMode)` tileMode) ` Create a shader that draws a radial gradient given the center and radius.                                                                                                                  |
| ` `[RadialGradient](https://developer.android.com/reference/android/graphics/RadialGradient#RadialGradient(float,%20float,%20float,%20long,%20long,%20android.graphics.Shader.TileMode))`(float centerX, float centerY, float radius, long centerColor, long edgeColor, `[Shader.TileMode](https://developer.android.com/reference/android/graphics/Shader.TileMode)` tileMode) ` Create a shader that draws a radial gradient given the center and radius.                                                                                                                 |
| ` `[RadialGradient](https://developer.android.com/reference/android/graphics/RadialGradient#RadialGradient(float,%20float,%20float,%20long[],%20float[],%20android.graphics.Shader.TileMode))`(float centerX, float centerY, float radius, long[] colors, float[] stops, `[Shader.TileMode](https://developer.android.com/reference/android/graphics/Shader.TileMode)` tileMode) ` Create a shader that draws a radial gradient given the center and radius.                                                                                                                |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.graphics.Shader](https://developer.android.com/reference/android/graphics/Shader)` ` |------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` boolean` | ` `[getLocalMatrix](https://developer.android.com/reference/android/graphics/Shader#getLocalMatrix(android.graphics.Matrix))`(`[Matrix](https://developer.android.com/reference/android/graphics/Matrix)` localM) ` Return true if the shader has a non-identity local matrix. | | ` void`    | ` `[setLocalMatrix](https://developer.android.com/reference/android/graphics/Shader#setLocalMatrix(android.graphics.Matrix))`(`[Matrix](https://developer.android.com/reference/android/graphics/Matrix)` localM) ` Set the shader's local matrix.                             | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### RadialGradient

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public RadialGradient (float startX, 
                float startY, 
                float startRadius, 
                float endX, 
                float endY, 
                float endRadius, 
                long[] colors, 
                float[] stops, 
                Shader.TileMode tileMode)
```

Create a shader that draws a radial gradient given the start and end points as well as starting and ending radii. The starting point is often referred to as the focal center and represents the starting circle of the radial gradient.

<br />

|                                                                                                                   Parameters                                                                                                                    ||
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `startX`      | `float`: The x-coordinate of the center of the starting circle of the radial gradient, often referred to as the focal point. <br />                                                                                              |
| `startY`      | `float`: The y-coordinate of the center of the starting circle of the radial gradient, often referred to as the focal point. <br />                                                                                              |
| `startRadius` | `float`: The radius of the starting circle of the radial gradient, often referred to as the focal radius. Must be greater than or equal to zero. Value is 0.0f or greater <br />                                                 |
| `endX`        | `float`: The x-coordinate of the center of the radius for the end circle of the radial gradient <br />                                                                                                                           |
| `endY`        | `float`: The y-coordinate of the center of the radius for the end circle of the radial gradient <br />                                                                                                                           |
| `endRadius`   | `float`: The radius of the ending circle for this gradient. This must be strictly greater than zero. A radius value equal to zero is not allowed. Value is 0.0f or greater <br />                                                |
| `colors`      | `long`: The colors to be distributed between the center and edge of the circle This value cannot be`null`. <br />                                                                                                                |
| `stops`       | `float`: May be`null`. Valid values are between`0.0f`and`1.0f`. The relative position of each corresponding color in the colors array. If`null`, colors are distributed evenly between the center and edge of the circle. <br /> |
| `tileMode`    | `Shader.TileMode`: The Shader tiling mode This value cannot be`null`. <br />                                                                                                                                                     |

|                                                                                                                                                                                                                                                                                   Throws                                                                                                                                                                                                                                                                                    ||
|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | In one of the following circumstances: - There are less than two colors - The colors do not share the same[ColorSpace](https://developer.android.com/reference/android/graphics/ColorSpace) - The colors do not use a valid[ColorSpace](https://developer.android.com/reference/android/graphics/ColorSpace) - The`stops`parameter is not`null`and has a different length from`colors`. - The`startRadius`is negative - The`endRadius`is less than or equal to zero |

### RadialGradient

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public RadialGradient (float centerX, 
                float centerY, 
                float radius, 
                int centerColor, 
                int edgeColor, 
                Shader.TileMode tileMode)
```

Create a shader that draws a radial gradient given the center and radius.

<br />

|                                         Parameters                                          ||
|---------------|------------------------------------------------------------------------------|
| `centerX`     | `float`: The x-coordinate of the center of the radius <br />                 |
| `centerY`     | `float`: The y-coordinate of the center of the radius <br />                 |
| `radius`      | `float`: Must be positive. The radius of the circle for this gradient <br /> |
| `centerColor` | `int`: The sRGB color at the center of the circle. <br />                    |
| `edgeColor`   | `int`: The sRGB color at the edge of the circle. <br />                      |
| `tileMode`    | `Shader.TileMode`: The Shader tiling mode This value cannot be`null`. <br /> |

### RadialGradient

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public RadialGradient (float centerX, 
                float centerY, 
                float radius, 
                int[] colors, 
                float[] stops, 
                Shader.TileMode tileMode)
```

Create a shader that draws a radial gradient given the center and radius.

<br />

|                                                                                                                  Parameters                                                                                                                  ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `centerX`  | `float`: The x-coordinate of the center of the radius <br />                                                                                                                                                                     |
| `centerY`  | `float`: The y-coordinate of the center of the radius <br />                                                                                                                                                                     |
| `radius`   | `float`: Must be positive. The radius of the circle for this gradient. <br />                                                                                                                                                    |
| `colors`   | `int`: The sRGB colors to be distributed between the center and edge of the circle This value cannot be`null`. <br />                                                                                                            |
| `stops`    | `float`: May be`null`. Valid values are between`0.0f`and`1.0f`. The relative position of each corresponding color in the colors array. If`null`, colors are distributed evenly between the center and edge of the circle. <br /> |
| `tileMode` | `Shader.TileMode`: The Shader tiling mode This value cannot be`null`. <br />                                                                                                                                                     |

### RadialGradient

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public RadialGradient (float centerX, 
                float centerY, 
                float radius, 
                long centerColor, 
                long edgeColor, 
                Shader.TileMode tileMode)
```

Create a shader that draws a radial gradient given the center and radius.

<br />

|                                         Parameters                                          ||
|---------------|------------------------------------------------------------------------------|
| `centerX`     | `float`: The x-coordinate of the center of the radius <br />                 |
| `centerY`     | `float`: The y-coordinate of the center of the radius <br />                 |
| `radius`      | `float`: Must be positive. The radius of the circle for this gradient <br /> |
| `centerColor` | `long`: The color at the center of the circle. <br />                        |
| `edgeColor`   | `long`: The color at the edge of the circle. <br />                          |
| `tileMode`    | `Shader.TileMode`: The Shader tiling mode This value cannot be`null`. <br /> |

|                                                                                                                         Throws                                                                                                                         ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the colors do not share the same[ColorSpace](https://developer.android.com/reference/android/graphics/ColorSpace)or do not use a valid one. |

### RadialGradient

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public RadialGradient (float centerX, 
                float centerY, 
                float radius, 
                long[] colors, 
                float[] stops, 
                Shader.TileMode tileMode)
```

Create a shader that draws a radial gradient given the center and radius.

<br />

|                                                                                                                  Parameters                                                                                                                  ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `centerX`  | `float`: The x-coordinate of the center of the radius <br />                                                                                                                                                                     |
| `centerY`  | `float`: The y-coordinate of the center of the radius <br />                                                                                                                                                                     |
| `radius`   | `float`: Must be positive. The radius of the circle for this gradient. <br />                                                                                                                                                    |
| `colors`   | `long`: The colors to be distributed between the center and edge of the circle This value cannot be`null`. <br />                                                                                                                |
| `stops`    | `float`: May be`null`. Valid values are between`0.0f`and`1.0f`. The relative position of each corresponding color in the colors array. If`null`, colors are distributed evenly between the center and edge of the circle. <br /> |
| `tileMode` | `Shader.TileMode`: The Shader tiling mode This value cannot be`null`. <br />                                                                                                                                                     |

|                                                                                                                                                                        Throws                                                                                                                                                                        ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if there are less than two colors, the colors do not share the same[ColorSpace](https://developer.android.com/reference/android/graphics/ColorSpace)or do not use a valid one, or`stops`is not`null`and has a different length from`colors`. |