override fun onCreate(savedInstanceState: Bundle?) {
requestWindowFeature(Window.FEATURE_NO_TITLE)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
val window = window
hideBottomUIMenu(window)
//监听底部栏
window.decorView.setOnSystemUiVisibilityChangeListener { hideBottomUIMenu(window) }
}
super.onCreate(savedInstanceState)
}
/**
* 隐藏虚拟按键,并且全屏
*/
protected open fun hideBottomUIMenu(window: Window) {
//隐藏虚拟按键,并且全屏
if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
val v = window.decorView
v.systemUiVisibility = View.GONE
} else if (Build.VERSION.SDK_INT >= 19) {
val params = window.attributes
params.systemUiVisibility =
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_IMMERSIVE
window.attributes = params
}
}
Android解决华为平板总是弹出导航栏隐藏不掉问题
最新推荐文章于 2024-09-11 15:13:15 发布