ColorBuilders.SweepGradient.Builder


public final class ColorBuilders.SweepGradient.Builder


Builder for SweepGradient.

Summary

Public constructors

@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
Builder(@NonNull ColorBuilders.ColorStop[] colorStops)

Creates an instance of Builder.

@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
Builder(@NonNull ColorBuilders.ColorProp[] colors)

Creates an instance of Builder.

Public methods

@NonNull ColorBuilders.SweepGradient

Builds an instance from accumulated values.

@NonNull ColorBuilders.SweepGradient.Builder

Sets the end angle of the gradient, relative to the element's base angle.

@NonNull ColorBuilders.SweepGradient.Builder

Sets the start angle of the gradient relative to the element's base angle.

Public constructors

Builder

@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
public Builder(@NonNull ColorBuilders.ColorStop[] colorStops)

Creates an instance of Builder.

Parameters
@NonNull ColorBuilders.ColorStop[] colorStops

The color stops defining how the colors are distributed around the gradient center.

A color stop is composed 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.

Throws
java.lang.IllegalArgumentException

if the number of colors is less than 2 or larger than 10.

Builder

@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
public Builder(@NonNull ColorBuilders.ColorProp[] colors)

Creates an instance of Builder.

The colors are evenly distributed in the gradient.

Parameters
@NonNull ColorBuilders.ColorProp[] colors

The color sequence to be distributed around the gradient center. The color sequence is distributed between the gradient's start and end angles.

Throws
java.lang.IllegalArgumentException

if the number of colors is less than 2 or larger than 10.

Public methods

build

Added in 1.1.0
public @NonNull ColorBuilders.SweepGradient build()

Builds an instance from accumulated values.

Throws
java.lang.IllegalStateException

if size of colorStops is less than 2 or greater than 10.

setEndAngle

Added in 1.1.0
@RequiresSchemaVersion(major = 1, minor = 300)
public @NonNull ColorBuilders.SweepGradient.Builder setEndAngle(@NonNull DimensionBuilders.DegreesProp endAngle)

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

For 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.

Note that this field only supports static values.

setStartAngle

Added in 1.1.0
@RequiresSchemaVersion(major = 1, minor = 300)
public @NonNull ColorBuilders.SweepGradient.Builder setStartAngle(@NonNull DimensionBuilders.DegreesProp startAngle)

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

For 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.

Note that this field only supports static values.