Timo Drick
04/02/2026, 7:53 AMfun Modifier.provideWindowInsetsRulers(
rulers: RectRulers
): Modifier = layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
layout(
width = placeable.width,
height = placeable.height,
rulers = {
val (w, h) = coordinates.size
<http://rulers.top|rulers.top> provides 100f
rulers.bottom provides h - 100f
rulers.left provides 100f
rulers.right provides w - 100f
}
) {
placeable.place(0, 0)
}
}
More details in the threadTimo Drick
04/02/2026, 7:54 AM@Preview
@Composable
fun RulerTestPreview() {
val rulers = WindowInsetsRulers.NavigationBars.current
val fitRulers = WindowInsetsRulers.NavigationBars.current
Box(
Modifier.fillMaxSize()
.provideWindowInsetsRulers(rulers)
.background(Color.Green)
.fitInside(fitRulers)
.background(Color.LightGray)
)
}
It works fine:Timo Drick
04/02/2026, 7:55 AMval fitRulers = WindowInsetsRulers.SafeDrawing.current then i get this:Timo Drick
04/02/2026, 7:56 AMval fitRulers = WindowInsetsRulers.StatusBars.current then i get this:Timo Drick
04/02/2026, 7:57 AMTimo Drick
04/03/2026, 7:58 AM