Draw a simple non-animating circular progress indicator.
CircularProgressIndicatorCustomAnimationSample
@Composable
fun CircularProgressIndicatorCustomAnimationSample() {
val animatedProgress = remember { Animatable(0f) }
val colors =
ProgressIndicatorDefaults.colors(indicatorColor = Color.Green, trackColor = Color.White)
LaunchedEffect(Unit) {
animatedProgress.animateTo(1f, tween(durationMillis = 1024, easing = LinearEasing))
animatedProgress.animateTo(0f, tween(durationMillis = 1024, easing = LinearEasing))
}
Box(
modifier =
Modifier.background(MaterialTheme.colorScheme.background)
.padding(CircularProgressIndicatorDefaults.FullScreenPadding)
.fillMaxSize()
) {
// Draw the circular progress indicator with custom animation
Spacer(
Modifier.fillMaxSize().focusable().drawBehind {
drawCircularProgressIndicator(
progress = animatedProgress.value,
strokeWidth = 10.dp,
colors = colors,
startAngle = 120f,
endAngle = 60f,
)
}
)
}
}