Function

drawCircularProgressIndicator

Draw a simple non-animating circular progress indicator.

CircularProgressIndicatorCustomAnimationSample

@Sampled
@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,
                )
            }
        )
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: