CircularProgressIndicator

Functions summary

Unit
@Composable
CircularProgressIndicator(
    modifier: Modifier,
    color: Color,
    strokeWidth: Dp,
    backgroundColor: Color,
    strokeCap: StrokeCap
)

Indeterminate Material Design circular progress indicator.

Cmn
Unit
@Composable
CircularProgressIndicator(
    progress: @FloatRange(from = 0.0, to = 1.0) Float,
    modifier: Modifier,
    color: Color,
    strokeWidth: Dp,
    backgroundColor: Color,
    strokeCap: StrokeCap
)

Determinate Material Design circular progress indicator.

Cmn

Functions

CircularProgressIndicator

@Composable
fun CircularProgressIndicator(
    modifier: Modifier = Modifier,
    color: Color = MaterialTheme.colors.primary,
    strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth,
    backgroundColor: Color = Color.Transparent,
    strokeCap: StrokeCap = StrokeCap.Square
): Unit

Indeterminate Material Design circular progress indicator.

Progress indicators express an unspecified wait time or display the length of a process.

Circular progress indicator
image

Parameters
modifier: Modifier = Modifier

the Modifier to be applied to this progress indicator

color: Color = MaterialTheme.colors.primary

The color of the progress indicator.

strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth

The stroke width for the progress indicator.

backgroundColor: Color = Color.Transparent

The color of the background behind the indicator, visible when the progress has not reached that area of the overall indicator yet.

strokeCap: StrokeCap = StrokeCap.Square

stroke cap to use for the ends of this progress indicator

CircularProgressIndicator

@Composable
fun CircularProgressIndicator(
    progress: @FloatRange(from = 0.0, to = 1.0) Float,
    modifier: Modifier = Modifier,
    color: Color = MaterialTheme.colors.primary,
    strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth,
    backgroundColor: Color = Color.Transparent,
    strokeCap: StrokeCap = StrokeCap.Butt
): Unit

Determinate Material Design circular progress indicator.

Progress indicators express an unspecified wait time or display the length of a process.

Circular progress indicator
image

By default there is no animation between progress values. You can use ProgressIndicatorDefaults.ProgressAnimationSpec as the default recommended AnimationSpec when animating progress, such as in the following example:

import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.OutlinedButton
import androidx.compose.material.ProgressIndicatorDefaults
import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

var progress by remember { mutableStateOf(0.1f) }
val animatedProgress by
    animateFloatAsState(
        targetValue = progress,
        animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
    )

Column(horizontalAlignment = Alignment.CenterHorizontally) {
    CircularProgressIndicator(progress = animatedProgress)
    Spacer(Modifier.requiredHeight(30.dp))
    OutlinedButton(onClick = { if (progress < 1f) progress += 0.1f }) { Text("Increase") }
}
Parameters
progress: @FloatRange(from = 0.0, to = 1.0) Float

The progress of this progress indicator, where 0.0 represents no progress and 1.0 represents full progress. Values outside of this range are coerced into the range.

modifier: Modifier = Modifier

the Modifier to be applied to this progress indicator

color: Color = MaterialTheme.colors.primary

The color of the progress indicator.

strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth

The stroke width for the progress indicator.

backgroundColor: Color = Color.Transparent

The color of the background behind the indicator, visible when the progress has not reached that area of the overall indicator yet.

strokeCap: StrokeCap = StrokeCap.Butt

stroke cap to use for the ends of this progress indicator