Activity全屏非全屏的切换

 /**
   * 设置全屏或非全屏
   *
   * @param activity
   * @param isFullScreen
 */
    public static void setIsFullScreen(Activity activity, boolean isFullScreen) {
        if (isFullScreen) {
            //设置为全屏
            activity.getWindow().setFlags(
                    WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        } else {
            //设置为非全屏
            final WindowManager.LayoutParams attrs = activity.getWindow().getAttributes();
            attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
            activity.getWindow().setAttributes(attrs);
            activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
    }

你可能感兴趣的:(Android基础)