/** * 调整状态栏文字、图标颜色 > 6.0 * true:白底黑字,false:黑底白字 */ funlightStatusBar(activity: Activity, light: Boolean = true) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return var window: Window = activity.window var visibility = window.decorView.systemUiVisibility visibility = if (light) { visibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR } else { visibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() } window.decorView.systemUiVisibility = visibility }
// 获取状态栏高度 fungetStatusBarHeight(activity: Activity): Int { var result: Int = 0 var resId = activity.resources.getIdentifier("status_bar_height", "dimen", "android") if (resId > 0) result = activity.resources.getDimensionPixelOffset(resId) return result } }
var options: Int = View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN // make content behind status bar | View.SYSTEM_UI_FLAG_LAYOUT_STABLE // keep layout stable | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide navigation bar | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION // make content behind navigation bar | View.SYSTEM_UI_FLAG_IMMERSIVE // immersive mode