Added in API level 1

LinearGradient


open class LinearGradient : Shader
kotlin.Any
   ↳ android.graphics.Shader
   ↳ android.graphics.LinearGradient

Summary

Public constructors
LinearGradient(x0: Float, y0: Float, x1: Float, y1: Float, color0: Int, color1: Int, tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

LinearGradient(x0: Float, y0: Float, x1: Float, y1: Float, colors: IntArray, positions: FloatArray?, tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

LinearGradient(x0: Float, y0: Float, x1: Float, y1: Float, color0: Long, color1: Long, tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

LinearGradient(x0: Float, y0: Float, x1: Float, y1: Float, colors: LongArray, positions: FloatArray?, tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

Inherited functions

Public constructors

LinearGradient

Added in API level 1
LinearGradient(
    x0: Float,
    y0: Float,
    x1: Float,
    y1: Float,
    color0: Int,
    color1: Int,
    tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

Parameters
x0 Float: The x-coordinate for the start of the gradient line
y0 Float: The y-coordinate for the start of the gradient line
x1 Float: The x-coordinate for the end of the gradient line
y1 Float: The y-coordinate for the end of the gradient line
color0 Int: The sRGB color at the start of the gradient line.
color1 Int: The sRGB color at the end of the gradient line.
tile Shader.TileMode: The Shader tiling mode This value cannot be null.

LinearGradient

Added in API level 1
LinearGradient(
    x0: Float,
    y0: Float,
    x1: Float,
    y1: Float,
    colors: IntArray,
    positions: FloatArray?,
    tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

Parameters
x0 Float: The x-coordinate for the start of the gradient line
y0 Float: The y-coordinate for the start of the gradient line
x1 Float: The x-coordinate for the end of the gradient line
y1 Float: The y-coordinate for the end of the gradient line
colors IntArray: The sRGB colors to be distributed along the gradient line This value cannot be null.
positions FloatArray?: May be null. The relative positions [0..1] of each corresponding color in the colors array. If this is null, the colors are distributed evenly along the gradient line.
tile Shader.TileMode: The Shader tiling mode This value cannot be null.

LinearGradient

Added in API level 29
LinearGradient(
    x0: Float,
    y0: Float,
    x1: Float,
    y1: Float,
    color0: Long,
    color1: Long,
    tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

Parameters
x0 Float: The x-coordinate for the start of the gradient line
y0 Float: The y-coordinate for the start of the gradient line
x1 Float: The x-coordinate for the end of the gradient line
y1 Float: The y-coordinate for the end of the gradient line
color0 Long: The color at the start of the gradient line.
color1 Long: The color at the end of the gradient line.
tile Shader.TileMode: The Shader tiling mode This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if the colors do not share the same ColorSpace or do not use a valid one.

LinearGradient

Added in API level 29
LinearGradient(
    x0: Float,
    y0: Float,
    x1: Float,
    y1: Float,
    colors: LongArray,
    positions: FloatArray?,
    tile: Shader.TileMode)

Create a shader that draws a linear gradient along a line.

Parameters
x0 Float: The x-coordinate for the start of the gradient line
y0 Float: The y-coordinate for the start of the gradient line
x1 Float: The x-coordinate for the end of the gradient line
y1 Float: The y-coordinate for the end of the gradient line
colors LongArray: The colors to be distributed along the gradient line This value cannot be null.
positions FloatArray?: May be null. The relative positions [0..1] of each corresponding color in the colors array. If this is null, the colors are distributed evenly along the gradient line.
tile Shader.TileMode: The Shader tiling mode This value cannot be null.
Exceptions
java.lang.IllegalArgumentException if there are less than two colors, the colors do not share the same ColorSpace or do not use a valid one, or positions is not null and has a different length from colors.