# ColorBuilders.SweepGradient

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.SweepGradient) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.1.0)

*** ** * ** ***


```
@RequiresSchemaVersion(major = 1, minor = 300)
public final class ColorBuilders.SweepGradient implements ColorBuilders.Brush
```

<br />

*** ** * ** ***

A sweep gradient with the given colors dispersed around its center with offsets defined in each color stop. The sweep begins at the parent's base angle plus the given angular shift and continues clockwise until it reaches the starting position again.

The gradient center corresponds to center of the parent element.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient.Builder` Builder for `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient`. |

| ### 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.SweepGradient#getColorStops()()` Gets the color stops defining how the colors are distributed around the gradient center. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient#getEndAngle()()` Gets the end angle of the gradient, relative to the element's base angle. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/DimensionBuilders.DegreesProp` | `https://developer.android.com/reference/androidx/wear/protolayout/ColorBuilders.SweepGradient#getStartAngle()()` Gets the start angle of the gradient relative to the element's base angle. |
| `@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.SweepGradient#toString()()` |

## Public methods

### getColorStops

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

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

Gets the color stops defining how the colors are distributed around the gradient center. The color sequence starts at the start angle and spans 360 degrees clockwise, finishing at the same angle.

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 from the start angle and ending with 1.0 at the end angle, spanning clockwise.

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.

### getEndAngle

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

```
public @NonNull DimensionBuilders.DegreesProp getEndAngle()
```

Gets the end angle of the gradient, relative to the element's base angle. If not set, defaults to 360 degrees.

For `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.ArcLine`, the base angle is the angle where the line starts. The value represents a relative position in the line's length span. Values greater than 360 degrees correspond to upper layers of the arc line as it wraps over itself.

### getStartAngle

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

```
public @NonNull DimensionBuilders.DegreesProp getStartAngle()
```

Gets the start angle of the gradient relative to the element's base angle. If not set, defaults to zero.

For `https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.ArcLine`, the base angle is the angle where the line starts. The value represents a relative position in the line's length span. Values greater than 360 degrees correspond to upper layers of the arc line as it wraps over itself.

### toString

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