通常的做法是这样的:
private static boolean isStatusbarVisible(Activity activity) {
int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
boolean isStatusbarHide = ((uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN) == uiOptions);
return !isStatusbarHide;
} public static void hideStatusBar(Activity activity) {
if (isStatusbarVisible(activity)) {
int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
uiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
activity.getWindow().getDecorView().setSystemUiVisibility(uiOptions);
}
}
此方法大多数情况都能奏效,但是遇到Drawerlayout就歇菜了。目前还没有找到解决办法。