{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ProgressSemanticsKt

public final class ProgressSemanticsKt


Summary

Public methods

static final @NonNull Modifier

Contains the semantics required for an indeterminate progress indicator, that represents the fact of the in-progress operation.

static final @NonNull Modifier
progressSemantics(
    @NonNull Modifier receiver,
    float value,
    @NonNull ClosedFloatingPointRange<@NonNull Float> valueRange,
    int steps
)

Contains the semantics required for a determinate progress indicator or the progress part of a slider, that represents progress within valueRange.

Public methods

progressSemantics

public static final @NonNull Modifier progressSemantics(@NonNull Modifier receiver)

Contains the semantics required for an indeterminate progress indicator, that represents the fact of the in-progress operation.

If you need determinate progress 0.0 to 1.0, consider using overload with the progress parameter.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.progressSemantics
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color

Box(Modifier.progressSemantics().background(color = Color.Cyan)) {
    Text("Operation is on progress")
}

progressSemantics

public static final @NonNull Modifier progressSemantics(
    @NonNull Modifier receiver,
    float value,
    @NonNull ClosedFloatingPointRange<@NonNull Float> valueRange,
    int steps
)

Contains the semantics required for a determinate progress indicator or the progress part of a slider, that represents progress within valueRange. value outside of this range will be coerced into this range.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.progressSemantics
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

val progress = 0.5f // emulate progress from some state
Box(
    Modifier
        .progressSemantics(progress)
        .size((progress * 100).dp, 4.dp)
        .background(color = Color.Cyan)
)
Parameters
float value

current value of the ProgressIndicator/Slider. If outside of valueRange provided, value will be coerced to this range. Must not be NaN.

@NonNull ClosedFloatingPointRange<@NonNull Float> valueRange

range of values that value can take. Passed value will be coerced to this range

int steps

if greater than 0, specifies the amounts of discrete values, evenly distributed between across the whole value range. If 0, any value from the range specified is allowed. Must not be negative.