通常,当使用伴奏时Modifier.statusBarsHeight(),高度将根据状态栏的可见性而变化,如果它可见,则为24.dp或更高,如果它不可见,则高度将为0.dp。但我希望无论其可见性如何,高度都不会变为零。
我已经使用这个有一段时间了:
// TODO: use better solution to get a fixed status bar height
val statusBarHeight = with (LocalDensity.current) { LocalWindowInsets.current.statusBars.top.toDp() }
val fixedStatusBarHeight = remember { statusBarHeight }
Run Code Online (Sandbox Code Playgroud)