Why `parentLayoutCoordinates.size` is `0 x 0` for ...
# compose
t
Why
parentLayoutCoordinates.size
is
0 x 0
for the first few items? More inside 🧵
👀 1
âž• 3
I’ve the below code
Copy code
@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
Copy code
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)
As you can see, the
size
is
0 x 0
for the first 6 items. Why’s that? 🤔
a
feel free to file a bug
âž• 1