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

Zoltan Demant

10/11/2023, 5:45 AM
WindowInsets.navigationBars.getBottom(LocalDensity.current)
always returns 0, then the actual value; is this by design, or a bug?
1
j

jossiwolf

10/11/2023, 9:25 AM
Where do you read it?
z

Zoltan Demant

10/11/2023, 11:31 AM
I can just put this code in setContent and see the same behavior! Saw it first when using it "outside" a
ModalBottomSheet
(to be used in the sheets contents).
i

Ian Lake

10/11/2023, 1:51 PM
Is your screen actually edge to edge (for example, does it use the Activity 1.8.0 API of
enableEdgeToEdge
)? By default, Android insets you automatically so you don't have any insets to handle unless you go edge to edge
z

Zoltan Demant

10/11/2023, 2:05 PM
Yup, I'm using edge to edge!
a

Alex Vanyo

10/11/2023, 5:34 PM
Sort of by design, as a limitation of the framework: https://developer.android.com/jetpack/compose/layouts/insets#insets-and-phases Composition is slightly too early for retrieving the actual insets values, since it is before the real inset values are known, which is corrected on the next composition. If you read the inset values in layout and measure, then you should get the correct value on the same frame that it is updated.
1
z

Zoltan Demant

10/12/2023, 4:43 AM
Awesome, then I wont look further into it! I was having an issue where my insets were seemingly ignored and I couldnt tell why; I was adjusting them with additional paddings, and so remembering the combined values .. so I never got the second, "real" value.
78 Views