LinearProgressIndicator

Functions summary

Unit
@Composable
LinearProgressIndicator(
    modifier: Modifier,
    color: Color,
    backgroundColor: Color,
    strokeCap: StrokeCap
)

Indeterminate Material Design linear progress indicator.

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

Determinate Material Design linear progress indicator.

Cmn

Functions

LinearProgressIndicator

@Composable
fun LinearProgressIndicator(
    modifier: Modifier = Modifier,
    color: Color = MaterialTheme.colors.primary,
    backgroundColor: Color = color.copy(alpha = IndicatorBackgroundOpacity),
    strokeCap: StrokeCap = StrokeCap.Butt
): Unit

Indeterminate Material Design linear progress indicator.

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

Linear 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.

backgroundColor: Color = color.copy(alpha = IndicatorBackgroundOpacity)

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

LinearProgressIndicator

@Composable
fun LinearProgressIndicator(
    progress: @FloatRange(from = 0.0, to = 1.0) Float,
    modifier: Modifier = Modifier,
    color: Color = MaterialTheme.colors.primary,
    backgroundColor: Color = color.copy(alpha = IndicatorBackgroundOpacity),
    strokeCap: StrokeCap = StrokeCap.Butt
): Unit

Determinate Material Design linear progress indicator.

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

Linear 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.LinearProgressIndicator
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) {
    LinearProgressIndicator(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.

backgroundColor: Color = color.copy(alpha = IndicatorBackgroundOpacity)

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