How to get status bar height #4049
Replies: 3 comments 1 reply
-
Try this: val statusBarPadding = WindowInsets.statusBars.asPaddingValues().calculateTopPadding() |
Beta Was this translation helpful? Give feedback.
-
I haven't found a direct way to obtain the height of the status bar, but it can be obtained by subtracting the maximum window height from the screen height.
|
Beta Was this translation helpful? Give feedback.
-
To get the statusbarheight or inset for compose you need to do the following. Step 1:
Step 2:
Step 3:
Or if you want to use any other insetPaddings you can use the WindowInsets class. I've read that a lot of people getting 0.0dp returned as there padding inset. That's because you forgot the setup part in step 1 and 2. Hope this helps :) |
Beta Was this translation helpful? Give feedback.
-
I tried to use
WindowInsets.statusBars.getBottom(<density>) and WindowInsets.statusBars.getTop(<density>)
, but both return 0.Beta Was this translation helpful? Give feedback.
All reactions