此方法只是基础的简单设置,没有做手机系统适配,可能在某些手机系统上不生效
#6200EE #FFFFFF #03DAC5
public static void setWindowStatusBarBlackColor(Activity activity) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { WindowInsetsController controller = activity.getWindow().getInsetsController(); controller.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS); }else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); }else { activity.getWindow().setStatusBarColor(Color.parseColor("#26000000")); } } catch (Exception e) { e.printStackTrace(); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)