Skip to content

Most visited

Recently visited


Hiding the Navigation Bar

This lesson teaches you to

  1. Hide the Navigation Bar
  2. Make Content Appear Behind the Navigation Bar

You should also read

Try it out

Get the sample

ImmersiveMode sample

This lesson describes how to hide the navigation bar, which was introduced in Android 4.0 (API level 14).

Even though this lesson focuses on hiding the navigation bar, you should design your app to hide the status bar at the same time, as described in Hiding the Status Bar. Hiding the navigation and status bars (while still keeping them readily accessible) lets the content use the entire display space, thereby providing a more immersive user experience.

system bars

Figure 1. Navigation bar.

Hide the Navigation Bar

You can hide the navigation bar using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
              | View.SYSTEM_UI_FLAG_FULLSCREEN;

Note the following:

Make Content Appear Behind the Navigation Bar

On Android 4.1 and higher, you can set your application's content to appear behind the navigation bar, so that the content doesn't resize as the navigation bar hides and shows. To do this, use SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION. You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.

When you use this approach, it becomes your responsibility to ensure that critical parts of your app's UI don't end up getting covered by system bars. For more discussion of this topic, see the Hiding the Status Bar lesson.

This site uses cookies to store your preferences for site-specific language and display options.


This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.