// 设置沉浸式布局标志位
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
frameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
frameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}
// 设置状态栏背景颜色
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT); // 将状态栏设置为透明
window.setNavigationBarColor(Color.BLACK); // 设置导航栏颜色
}