https://kotlinlang.org logo
r

rsktash

12/27/2021, 4:02 AM
hi how can I detect if a composable is in a visible area of the device screen?
r

Rafs

12/27/2021, 9:45 AM
You can use
Modifier.onPlaced
as it gives you a lot of layout information after the parent layout has been placed.
Copy code
Modifier.onPlaced { layoutCoordinates ->
  val (x, y) = layoutCoordinates.positionInParent()
}
in a
Row
or a
Column
layout, a positive
x
or
y
value means the composable is within the bounds of its parent. A negative value means the composable is going out of view.