Progress indicators express an unspecified wait time or display the duration of a process.
IndeterminateLinearProgressIndicatorSample
@Preview
@Composable
fun IndeterminateLinearProgressIndicatorSample() {
Column(horizontalAlignment = Alignment.CenterHorizontally) { LinearProgressIndicator() }
}
LinearProgressIndicatorSample
@Preview
@Composable
fun LinearProgressIndicatorSample() {
var progress by remember { mutableFloatStateOf(0.1f) }
val animatedProgress by
animateFloatAsState(
targetValue = progress,
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
)
Column(horizontalAlignment = Alignment.CenterHorizontally) {
LinearProgressIndicator(progress = { animatedProgress })
Spacer(Modifier.requiredHeight(30.dp))
Text("Set progress:")
Slider(
modifier = Modifier.width(300.dp),
value = progress,
valueRange = 0f..1f,
onValueChange = { progress = it },
)
}
}