theapache64
12/31/2021, 12:27 PMparentLayoutCoordinates.size
is 0 x 0
for the first few items? More inside 🧵theapache64
12/31/2021, 12:28 PM@Composable
fun Test1() {
LazyRow {
items(100) { id ->
Box(
modifier = Modifier
.padding(end = 10.dp)
.size(100.dp)
.background(Color.Red)
.onGloballyPositioned { layoutCoordinates ->
println("$id -> parentSize: ${layoutCoordinates.parentLayoutCoordinates?.size}")
}
){
Text("$id")
}
}
}
}
and here’s the log
0 -> parentSize: 0 x 0
1 -> parentSize: 0 x 0
2 -> parentSize: 0 x 0
3 -> parentSize: 0 x 0
4 -> parentSize: 0 x 0
5 -> parentSize: 0 x 0
6 -> parentSize: 1080 x 263
7 -> parentSize: 1080 x 263
8 -> parentSize: 1080 x 263
9 -> parentSize: 1080 x 263
... (printing size for rest of the items)
theapache64
12/31/2021, 12:29 PMtheapache64
12/31/2021, 12:30 PMsize
is 0 x 0
for the first 6 items.
Why’s that? 🤔Andrey Kulikov
01/10/2022, 5:18 PM