set Full Screen - Android android.app

Android examples for android.app:Screen

Description

set Full Screen

Demo Code

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

public class Main {

  public static void setFullScreen(Activity activity) {
    toggleFullScreen(activity, true);/*from w w  w . j  av a  2 s .  c  o  m*/
  }

  public static void toggleFullScreen(Activity activity, boolean isFull) {
    hideTitleBar(activity);
    Window window = activity.getWindow();
    WindowManager.LayoutParams params = window.getAttributes();
    if (isFull) {
      params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
      window.setAttributes(params);
      window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    } else {
      params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
      window.setAttributes(params);
      window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    }
  }

  public static void hideTitleBar(Activity activity) {
    activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
  }
}

Related Tutorials