Hi guys I have a question on windowInsets and how ...
# android
n
Hi guys I have a question on windowInsets and how it works when the app is no longer in the foreground. For starters I have a full compose app, with just one activity calling
WindowCompat.setDecorFitsSystemWindows(window, false)
to let me draw behind the systembars. So all my compose views (that need it ofc) calls
Modifier.systemBarPadding()
for statusbar and navbar padding, and it works as expected. But I’ve found that calling for example an Intent chooser to pick an app to open like an installed email app, makes the
systemBarPadding()
return 0 and my layout jumps to underneath the status bar. And it’s all very visible since the dialog from the Intent chooser is not covering the entire screen. Any tips on how I can make
systemBarPadding()
keeping it’s value even after the app is not in the foreground anymore? Thanks for any help.
i
Not sure if it is a good solution but it’s working for me. You could save the height of status bar in some global repository that is live in background or in a shared preferences. In main activity code:
Copy code
val statusBarHeight = resources.getDimensionPixelSize(statusBarHeightId)
globalRepository.statusBarHeight = statusBarHeight.dpFromPx(applicationContext)
n
I could look in to having something like that.