# ColorBuilders.LinearGradient

# ColorBuilders.LinearGradient

Artifact:[androidx.wear.protolayout:protolayout](https://developer.android.com/jetpack/androidx/releases/wear-protolayout)  
[View Source](https://cs.android.com/search?q=file:androidx/wear/protolayout/ColorBuilders.java+class:androidx.wear.protolayout.ColorBuilders.LinearGradient)  
Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient "View this page in Java")

<br />

```
@RequiresSchemaVersion(major = 1, minor = 500)
class ColorBuilders.LinearGradient : ColorBuilders.Brush
```

<br />

*** ** * ** ***

A linear gradient with the provided colors based on defined start and end coordinates.

The colors are dispersed at the offsets defined in each color stop.

## Summary

|                                                                                                                                         ### Nested types                                                                                                                                          |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[ColorBuilders.LinearGradient.Builder](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient.Builder) Builder for[LinearGradient](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient). |

|                                                                                                                                                         ### Public functions                                                                                                                                                          |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `(`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[ColorBuilders.ColorStop](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.ColorStop)`!>` | [getColorStops](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient#getColorStops())`()` Gets the color stops defining how the colors are distributed from the start to the end coordinates. |
| [DimensionBuilders.OffsetDimension](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.OffsetDimension)`?`                                                                                                                                                                                    | [getEndX](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient#getEndX())`()` Gets the ending y position of the linear gradient.                                                              |
| [DimensionBuilders.OffsetDimension](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.OffsetDimension)`?`                                                                                                                                                                                    | [getEndY](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient#getEndY())`()` Gets the ending y position of the linear gradient.                                                              |
| [DimensionBuilders.OffsetDimension](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.OffsetDimension)`?`                                                                                                                                                                                    | [getStartX](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient#getStartX())`()` Gets the starting x position of the linear gradient.                                                        |
| [DimensionBuilders.OffsetDimension](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/DimensionBuilders.OffsetDimension)`?`                                                                                                                                                                                    | [getStartY](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient#getStartY())`()` Gets the starting y position of the linear gradient.                                                        |
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                                                                                                                                                                     | [toString](https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ColorBuilders.LinearGradient#toString())`()`                                                                                                               |

## Public functions

### getColorStops

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun getColorStops(): (Mutable)List<ColorBuilders.ColorStop!>
```

Gets the color stops defining how the colors are distributed from the start to the end coordinates.

A color stop is a pair of a color and its offset in the gradient. The offset is the relative position of the color, beginning with 0 at the start coordinate and ending with 1.0 at the end coordinate.

There must be at least 2 colors and at most 10 colors.

If offset values are not set, the colors are evenly distributed in the gradient.  

### getEndX

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun getEndX(): DimensionBuilders.OffsetDimension?
```

Gets the ending y position of the linear gradient. Defaults to the right side of the element.  

### getEndY

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun getEndY(): DimensionBuilders.OffsetDimension?
```

Gets the ending y position of the linear gradient. Defaults to the top side of the element.  

### getStartX

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun getStartX(): DimensionBuilders.OffsetDimension?
```

Gets the starting x position of the linear gradient. Defaults to the left side of the element.  

### getStartY

Added in[1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)  

```
fun getStartY(): DimensionBuilders.OffsetDimension?
```

Gets the starting y position of the linear gradient. Defaults to the top side of the element.  

### toString

```
fun toString(): String
```