5

The following doesn't work. When I scroll, the width of the first panel fluctuates.

compose version = 1.0.0-beta01

@Composable
fun Carousel() {
    val panels = listOf(Pair("cat", Color.Blue), Pair("dog", Color.Cyan), Pair("snake", Color.Green))

    LazyRow(
        modifier = Modifier
            .fillMaxSize()
    ) {
        items(panels) { panel ->
            Column(
                modifier = Modifier
                    .fillParentMaxSize()
                    .background(panel.second),
                verticalArrangement = Arrangement.Center,
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                Text(
                    text = panel.first
                )
            }
        }
    }
}
nociceptus
  • 71
  • 1
  • 6

2 Answers2

10

Replace fillParentMaxSize() with fillParentMaxWidth() and it will work as expected.

Amirhosein
  • 1,048
  • 7
  • 19
2

It should work, it has been accepted as a bug.

See https://issuetracker.google.com/issues/182490045

nociceptus
  • 71
  • 1
  • 6