public static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) { Class<? extends Window> clazz = activity.getWindow().getClass(); try { int darkModeFlag = 0; Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); darkModeFlag = field.getInt(layoutParams); Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class); extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag); return true; } catch (Exception e) { e.printStackTrace(); } return false; }适配小米
修改手机状态栏字体颜色
最新推荐文章于 2024-05-11 21:58:45 发布