//设置没有标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE)
//设置状态透明及状态栏为黑色字体
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
//设置状态栏及底部导航栏透明
window?.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
//设置状态栏的高度
val relativeLayout = findViewById<RelativeLayout>(R.id.result_title)
if (relativeLayout != null) {
val lp = RelativeLayout.LayoutParams(relativeLayout.layoutParams.width, relativeLayout.layoutParams.height)
lp.setMargins(0, getStatusBarHeight(), 0, 0)
relativeLayout.layoutParams = lp
}
//获取状态栏的高度
protected fun getStatusBarHeight(): Int {
var result = 0
// Obtain the ID.
if (resources != null) {
val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
if (resourceId > 0) {
result = resources.getDimensionPixelSize(resourceId)
}
}
return result
}