LoadingIndicator

Functions summary

Unit
@ExperimentalMaterial3ExpressiveApi
@Composable
LoadingIndicator(
    modifier: Modifier,
    color: Color,
    polygons: List<RoundedPolygon>
)

A Material Design loading indicator.

Cmn
Unit
@ExperimentalMaterial3ExpressiveApi
@Composable
LoadingIndicator(
    progress: () -> Float,
    modifier: Modifier,
    color: Color,
    polygons: List<RoundedPolygon>
)

A Material Design loading indicator.

Cmn

Functions

LoadingIndicator

@ExperimentalMaterial3ExpressiveApi
@Composable
fun LoadingIndicator(
    modifier: Modifier = Modifier,
    color: Color = LoadingIndicatorDefaults.indicatorColor,
    polygons: List<RoundedPolygon> = LoadingIndicatorDefaults.IndeterminateIndicatorPolygons
): Unit

A Material Design loading indicator.

This version of the loading indicator animates and morphs between various shapes as long as the loading indicator is visible.

Loading indicator
image

It can be created like this:

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.LoadingIndicator
import androidx.compose.ui.Alignment

Column(horizontalAlignment = Alignment.CenterHorizontally) { LoadingIndicator() }
Parameters
modifier: Modifier = Modifier

the Modifier to be applied to this loading indicator

color: Color = LoadingIndicatorDefaults.indicatorColor

the loading indicator's color

polygons: List<RoundedPolygon> = LoadingIndicatorDefaults.IndeterminateIndicatorPolygons

a list of RoundedPolygons for the sequence of shapes this loading indicator will morph between. The loading indicator expects at least two items in that list.

Throws
IllegalArgumentException

if the polygons list holds less than two items

LoadingIndicator

@ExperimentalMaterial3ExpressiveApi
@Composable
fun LoadingIndicator(
    progress: () -> Float,
    modifier: Modifier = Modifier,
    color: Color = LoadingIndicatorDefaults.indicatorColor,
    polygons: List<RoundedPolygon> = LoadingIndicatorDefaults.DeterminateIndicatorPolygons
): Unit

A Material Design loading indicator.

This version of the loading indicator morphs between its polygons shapes by the value of its progress.

Loading indicator
image

It can be created like this:

import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.spring
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.width
import androidx.compose.material3.LoadingIndicator
import androidx.compose.material3.Slider
import androidx.compose.material3.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
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 { mutableFloatStateOf(0f) }
val animatedProgress by
    animateFloatAsState(
        targetValue = progress,
        animationSpec =
            spring(
                dampingRatio = Spring.DampingRatioNoBouncy,
                stiffness = Spring.StiffnessVeryLow,
                visibilityThreshold = 1 / 1000f,
            ),
    )

Column(horizontalAlignment = Alignment.CenterHorizontally) {
    LoadingIndicator(progress = { animatedProgress })
    Spacer(Modifier.requiredHeight(30.dp))
    Text("Set loading progress:")
    Slider(
        modifier = Modifier.width(300.dp),
        value = progress,
        valueRange = 0f..1f,
        onValueChange = { progress = it },
    )
}
Parameters
progress: () -> Float

the progress of this loading indicator, where 0.0 represents no progress and 1.0 represents full progress. Values outside of this range are coerced into the range. The indicator will morph its shapes between the provided polygons according to the value of the progress.

modifier: Modifier = Modifier

the Modifier to be applied to this loading indicator

color: Color = LoadingIndicatorDefaults.indicatorColor

the loading indicator's color

polygons: List<RoundedPolygon> = LoadingIndicatorDefaults.DeterminateIndicatorPolygons

a list of RoundedPolygons for the sequence of shapes this loading indicator will morph between as it progresses from 0.0 to 1.0. The loading indicator expects at least two items in that list.

Throws
IllegalArgumentException

if the polygons list holds less than two items