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

*** ** * ** ***


```
@RequiresSchemaVersion(major = 1, minor = 500)
public final class ColorBuilders.LinearGradient implements 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 |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.ColorStop>` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient#getColorStops()()` Gets the color stops defining how the colors are distributed from the start to the end coordinates. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient#getEndX()()` Gets the ending y position of the linear gradient. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient#getEndY()()` Gets the ending y position of the linear gradient. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient#getStartX()()` Gets the starting x position of the linear gradient. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.OffsetDimension` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient#getStartY()()` Gets the starting y position of the linear gradient. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.LinearGradient#toString()()` |

## Public methods

### getColorStops

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

```
public @NonNull List<ColorBuilders.ColorStop> getColorStops()
```

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)

```
public @Nullable DimensionBuilders.OffsetDimension getEndX()
```

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)

```
public @Nullable DimensionBuilders.OffsetDimension getEndY()
```

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)

```
public @Nullable DimensionBuilders.OffsetDimension getStartX()
```

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)

```
public @Nullable DimensionBuilders.OffsetDimension getStartY()
```

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

### toString

```
public @NonNull String toString()
```