CircularProgressIndicatorKt

Added in 1.3.0-alpha06

public final class CircularProgressIndicatorKt


Summary

Public methods

static final @NonNull LayoutElementBuilders.LayoutElement
circularProgressIndicator(
    @NonNull MaterialScope receiver,
    float staticProgress,
    DynamicBuilders.DynamicFloat dynamicProgress,
    @NonNull LayoutModifier modifier,
    float startAngleDegrees,
    float endAngleDegrees,
    @Dimension(unit = 0) float strokeWidth,
    @Dimension(unit = 0) float gapSize,
    @NonNull ProgressIndicatorColors colors,
    @NonNull DimensionBuilders.ContainerDimension size
)

Protolayout Material3 design circular progress indicator.

Public methods

circularProgressIndicator

public static final @NonNull LayoutElementBuilders.LayoutElement circularProgressIndicator(
    @NonNull MaterialScope receiver,
    float staticProgress,
    DynamicBuilders.DynamicFloat dynamicProgress,
    @NonNull LayoutModifier modifier,
    float startAngleDegrees,
    float endAngleDegrees,
    @Dimension(unit = 0) float strokeWidth,
    @Dimension(unit = 0) float gapSize,
    @NonNull ProgressIndicatorColors colors,
    @NonNull DimensionBuilders.ContainerDimension size
)

Protolayout Material3 design circular progress indicator.

import androidx.wear.protolayout.DimensionBuilders.dp
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicFloat
import androidx.wear.protolayout.material3.CircularProgressIndicatorDefaults
import androidx.wear.protolayout.material3.CircularProgressIndicatorDefaults.filledVariantProgressIndicatorColors
import androidx.wear.protolayout.material3.circularProgressIndicator
import androidx.wear.protolayout.material3.materialScope
import androidx.wear.protolayout.material3.text

materialScope(context, deviceParameters) {
        circularProgressIndicator(
            dynamicProgress =
                DynamicFloat.animate(
                    0.0F,
                    1.1F,
                    CircularProgressIndicatorDefaults.recommendedAnimationSpec
                ),
            startAngleDegrees = 200F,
            endAngleDegrees = 520F,
            colors = filledVariantProgressIndicatorColors(),
            size = dp(85F)
        )
    }
Parameters
float staticProgress

The static progress of this progress indicator where 0 represent no progress and 1 represents completion. Progress above 1 is also allowed. If dynamicProgress is also set, this static value will be ignored. By default it equals to 0.

DynamicBuilders.DynamicFloat dynamicProgress

The static progress of this progress indicator where 0 represent no progress and 1 represents completion. Progress above 1 is also allowed. If not provided, the staticProgress is used.

@NonNull LayoutModifier modifier

Modifiers to set to this element. It's highly recommended to set a content description using contentDescription.

float startAngleDegrees

The starting position of the progress arc, measured clockwise in degrees from the 12 o'clock position.

float endAngleDegrees

The ending position of the progress arc, measured clockwise in degrees from 12 o'clock position. Its value must be bigger than startAngleDegrees, otherwise an exception would be thrown. By default it equals to 'startAngleDegrees + 360'.

@Dimension(unit = 0) float strokeWidth

The stroke width for the progress indicator. The recommended values are CircularProgressIndicatorDefaults.LARGE_STROKE_WIDTH and CircularProgressIndicatorDefaults.SMALL_STROKE_WIDTH.

@Dimension(unit = 0) float gapSize

The size in dp of the gap between the ends of the progress indicator and the track. The stroke end caps are not included in this distance.

@NonNull ProgressIndicatorColors colors

ProgressIndicatorColors that will be used to resolve the indicator and track color for this progress indicator.

@NonNull DimensionBuilders.ContainerDimension size

The bounding box size of this progress indicator, applies to both width and height. The indicator arc and track arc are located on the largest circle that can be inscribed inside. It is highly recommended for the progress indicator in a graphics card to have its size as ExpandedDimensionProp, which is the default, to fill the available space for the best result across different screen sizes. Setting size with a WrappedDimensionProp instance will cause failure and throws an IllegalArgumentException.

Throws
kotlin.IllegalArgumentException

When size is set to be WrappedDimensionProp instance or the provided endAngleDegrees is smaller than the startAngleDegrees.