Langsung ke konten

Paling sering dikunjungi

Terakhir dikunjungi

navigation

Dimming the System Bars

This lesson teaches you to

  1. Dim the Status and Navigation Bars
  2. Reveal the Status and Navigation Bars

You should also read

Try it out

Get the sample

ImmersiveMode sample

This lesson describes how to dim the system bars (that is, the status and the navigation bars) on Android 4.0 (API level 14) and higher. Android does not provide a built-in way to dim the system bars on earlier versions.

When you use this approach, the content doesn't resize, but the icons in the system bars visually recede. As soon as the user touches either the status bar or the navigation bar area of the screen, both bars become fully visible. The advantage of this approach is that the bars are still present but their details are obscured, thus creating an immersive experience without sacrificing easy access to the bars.

Dim the Status and Navigation Bars

You can dim the status and notification bars using the SYSTEM_UI_FLAG_LOW_PROFILE flag, as follows:

// This example uses decor view, but you can use any visible view.
View decorView = getActivity().getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;
decorView.setSystemUiVisibility(uiOptions);

As soon as the user touches the status or navigation bar, the flag is cleared, causing the bars to be undimmed. Once the flag has been cleared, your app needs to reset it if you want to dim the bars again.

Figure 1 shows a gallery image in which the navigation bar is dimmed (note that the Gallery app completely hides the status bar; it doesn't dim it). Notice that the navigation bar (right side of the image) has faint white dots on it to represent the navigation controls:

system bars

Figure 1. Dimmed system bars.

Figure 2 shows the same gallery image, but with the system bars displayed:

system bars

Figure 2. Visible system bars.

Reveal the Status and Navigation Bars

If you want to programmatically clear flags set with setSystemUiVisibility(), you can do so as follows:

View decorView = getActivity().getWindow().getDecorView();
// Calling setSystemUiVisibility() with a value of 0 clears
// all flags.
decorView.setSystemUiVisibility(0);
Situs ini menggunakan cookies untuk menyimpan preferensi Anda tentang bahasa di situs tertentu dan opsi tampilan.

Dapatkan berita dan tips terbaru dari developer Android yang akan membantu Anda mencapai kesuksesan di Google Play.

* Wajib Diisi

Hore!

Ikuti Google Developers di WeChat

Buka situs ini dalam bahasa ?

Anda meminta halaman dalam bahasa , namun preferensi bahasa untuk situs ini adalah .

Ingin mengubah preferensi bahasa dan mengakses situs ini dalam bahasa ? Jika nanti Anda ingin mengubah preferensi bahasa, gunakan menu bahasa di bagian bawah setiap halaman.

Kelas ini memerlukan tingkat API atau yang lebih tinggi

Dokumen ini tersembunyi karena level API yang Anda pilih untuk dokumentasi ini adalah . Anda dapat mengubah level API dokumentasi dengan pemilih di atas menu navigasi sebelah kiri.

Untuk informasi lebih lanjut tentang menentukan level API yang diperlukan aplikasi Anda, baca Mendukung Versi Platform Yang Berbeda.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)