Progress indicators express an unspecified wait time or display the duration of a process.
IndeterminateLinearWavyProgressIndicatorSample
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Preview
@Composable
fun IndeterminateLinearWavyProgressIndicatorSample() {
Column(horizontalAlignment = Alignment.CenterHorizontally) { LinearWavyProgressIndicator() }
}
LinearThickWavyProgressIndicatorSample
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Preview
@Composable
fun LinearThickWavyProgressIndicatorSample() {
var progress by remember { mutableFloatStateOf(0.1f) }
val animatedProgress by
animateFloatAsState(
targetValue = progress,
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
)
val thickStrokeWidth = with(LocalDensity.current) { 8.dp.toPx() }
val thickStroke =
remember(thickStrokeWidth) { Stroke(width = thickStrokeWidth, cap = StrokeCap.Round) }
Column(horizontalAlignment = Alignment.CenterHorizontally) {
LinearWavyProgressIndicator(
progress = { animatedProgress },
// Thick height is slightly higher than the
// WavyProgressIndicatorDefaults.LinearContainerHeight default
modifier = Modifier.height(14.dp),
stroke = thickStroke,
trackStroke = thickStroke,
)
Spacer(Modifier.requiredHeight(30.dp))
Text("Set progress:")
Slider(
modifier = Modifier.width(300.dp),
value = progress,
valueRange = 0f..1f,
onValueChange = { progress = it },
)
}
}
LinearWavyProgressIndicatorSample
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Preview
@Composable
fun LinearWavyProgressIndicatorSample() {
var progress by remember { mutableFloatStateOf(0.1f) }
val animatedProgress by
animateFloatAsState(
targetValue = progress,
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
)
Column(horizontalAlignment = Alignment.CenterHorizontally) {
LinearWavyProgressIndicator(progress = { animatedProgress })
Spacer(Modifier.requiredHeight(30.dp))
Text("Set progress:")
Slider(
modifier = Modifier.width(300.dp),
value = progress,
valueRange = 0f..1f,
onValueChange = { progress = it },
)
}
}