书法字典:https://www.shufadict.com

Android 隐藏系统状态栏

通常的做法是这样的:

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就歇菜了。目前还没有找到解决办法。

posted on 2018-03-18 20:43  翰墨小生  阅读(4132)  评论(1编辑  收藏  举报

导航

书法字典:https://www.shufadict.com