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