大家讲道理2017-04-18 09:09:53
Let’s recommend an article that introduces the status bar in detail. Not all Android systems can modify the status bar to black text on a white background. It depends on whether the system provides an API. Android itself does not support such operations. Domestic Android systems have been customized, and some have open interfaces, such as Xiaomi and Meizu.
Android status bar operation, everything you want to know is here
PHP中文网2017-04-18 09:09:53
Xiaomi and Meizu have public methods to set the status bar font color.
public static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) {
Class<? extends Window> clazz = activity.getWindow().getClass();
try {
int darkModeFlag;
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;
}
Meizu, uh uh, look for it online, I remember I had it before, but I couldn’t find it for a while.
PS: Android 6.0 seems to work too.