https://kotlinlang.org logo
Title
a

Alex

06/27/2022, 4:20 PM
I can add system bars padding via
systemBarsPadding()
, is there a way to get the height of the system bars in
dp
instead of applying the padding directly?
m

MR3Y

06/27/2022, 4:31 PM
WindowInsets.systemBars
?
Also, see https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets for the available methods & operators to get specific paddings (left, top....etc)
:thank-you: 1
j

Ji Sungbin

06/27/2022, 5:55 PM
here:
val NavigationBarHeightDp
    @Composable
    get() = with(LocalDensity.current) {
        WindowInsets.systemBars.getBottom(this).toDp()
    }

val StatusBarHeightDp
    @Composable
    get() = with(LocalDensity.current) {
        WindowInsets.systemBars.getTop(this).toDp()
    }
:thank-you: 1
a

Alex

06/28/2022, 7:11 AM
Man, thanks a lot. I couldn’t easily find this information. Great to hear there is an easy solution!
m

Marcin Wisniowski

06/30/2022, 3:56 PM
@Ji Sungbin Doesn't this assume the navigation bar is horizontal? It won't work in landscape mode if that's the case.
j

Ji Sungbin

06/30/2022, 4:04 PM
Oh right, I didn’t even think of that. thanks for pointing it out!