https://kotlinlang.org logo
a

AG

07/05/2020, 3:40 PM
Hello, can someone help me to figure out how to make
LazyRowItems
with
wrap content
inside
LazyColumnItems
work correctly. In this example I have a row with images where each image has width 100dp. When I’m not passing modifier value with height in
LazyRowItems
it shows only one row and Text is not rendering , also it’s possible to scroll the page, but when I’m passing modifier with
preferredHeight
all works correctly,
wrapContentHeight
not working also.
Copy code
LazyColumnItems(items = List(size = 30, init = { it })) { column ->
    if (column % 2 == 0) {
        LazyRowItems(
            items = List(size = 30, init = { it })
            //modifier = Modifier.preferredHeight(100.dp)
        ) { row ->
            Image(
                asset = imageAsset,
                modifier = Modifier.wrapContentHeight(100.dp).aspectRatio(1f)
            )
        }
    } else {
        Text(text = "$column")
    }
}
a

Andrey Kulikov

07/05/2020, 8:14 PM
hey, wrap content behaviour for LazyColumnItems is not yet supported, so yes, your approach with defining a size is the best workaround for now
a

AG

07/05/2020, 8:36 PM
ok, thanks @Andrey Kulikov 👍
3 Views