https://kotlinlang.org logo
#compose
Title
# compose
t

theapache64

12/31/2021, 12:27 PM
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

Andrey Kulikov

01/10/2022, 5:18 PM
feel free to file a bug
1
4 Views