auto hide android navbar (#133)
* auto hide android navbar * auto hide android navbar
This commit is contained in:
parent
bd6197031a
commit
61150066bd
3 changed files with 16 additions and 16 deletions
|
@ -157,11 +157,22 @@ fun initActivity(a: Activity) {
|
|||
}
|
||||
}
|
||||
a.hideStatusBar()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && statusBarHeight == 0 && a.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
window.decorView.rootWindowInsets?.displayCutout?.apply {
|
||||
if (boundingRects.size > 0) {
|
||||
statusBarHeight = min(boundingRects[0].width(), boundingRects[0].height())
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R &&
|
||||
statusBarHeight == 0 &&
|
||||
a.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||
) {
|
||||
window.setDecorFitsSystemWindows(false)
|
||||
|
||||
window.decorView.setOnApplyWindowInsetsListener { _, insets ->
|
||||
statusBarHeight = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top
|
||||
navBarHeight = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom
|
||||
insets
|
||||
}
|
||||
|
||||
window.insetsController?.let { controller ->
|
||||
controller.systemBarsBehavior =
|
||||
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
controller.hide(WindowInsetsCompat.Type.navigationBars())
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue