1.先上效果图
2.直接上代码,复制粘贴并引用即可。
public static void setNavigationBarStatusBarTranslucent(Activity activity){
if (Build.VERSION.SDK_INT >= 21) {
View decorView = activity.getWindow().getDecorView();
int option = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
;
decorView.setSystemUiVisibility(option);
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
// activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}