Android How to - Toggle Full Screen Settings








Question

We would like to know how to toggle Full Screen Settings.

Answer

//from  w  ww  .  j  av  a  2s .  co  m

import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;

public class Main {
  public static void toggleFullScreen(Activity activity, boolean isFull) {
    Window window = activity.getWindow();
    WindowManager.LayoutParams winParams = window.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
    if (isFull) {
      winParams.flags |= bits;
    } else {
      winParams.flags &= ~bits;
    }
    window.setAttributes(winParams);
  }


  public static void setFullScreen(Activity activity) {
    toggleFullScreen(activity, true);
  }

}