修改MIUI
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;
}
上面为小米官方提供的解决方案,主要为MIUI内置了可以修改状态栏的模式,支持Dark和Light两种模式。
修改Flyme
public static boolean setMeizuStatusBarDarkIcon(Activity activity, boolean dark) {
boolean result = false;
if (activity != null) {
try {
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
Field darkFlag = WindowManager.Layo