Jetpack Compose Fill Container Height/Width With ProgressBar

November 7, 2021
var progress by remember { mutableStateOf(0f) }

Card(
    modifier = Modifier
        .fillMaxWidth()
        .height(IntrinsicSize.Min)
        .padding(8.dp),
    onClick = { progress += 0.1f }
) {

    Row {
        Image(data = uri)
        Text(
            modifier = Modifier
                .padding(8.dp)
                .align(Alignment.CenterVertically),
            text = "Album Name",
            // style = MaterialTheme.typography.h5
        )

    }

    // this progress bar will fill the entire height+width of Card
    if (progress >= 0f) {
        LinearProgressIndicator(
            progress = progress,
            modifier = Modifier.fillMaxHeight(),
            color = MaterialTheme.colors.primary.copy(alpha = 0.3f)
        )
    }
}                

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.