hide Navigation Bar - Android android.app

Android examples for android.app:Window

Description

hide Navigation Bar

Demo Code

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.view.Window;

public class Main {
  @TargetApi(19)// w  w w  . j a v a 2  s.c o m
  public static void hideNavigationBar(Activity activity) {

    if (Build.VERSION.SDK_INT < 14) {
      return;
    }

    int uiFlags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;

    if (Build.VERSION.SDK_INT >= 16) {
      uiFlags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
    }

    if (android.os.Build.VERSION.SDK_INT >= 19) {
      uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    }

    Window win = activity.getWindow();
    View docView = win.getDecorView();
    docView.setSystemUiVisibility(uiFlags);
  }

}

Related Tutorials