How to hide the status bar and navigation bar on Android?

To hide the status bar and navigation bar on an Android device, you can use the following methods:

  1. To use full-screen mode in an Activity:
    Add the following code in the onCreate() method of the Activity.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

This will cause the Activity to enter full-screen mode, with both the status bar and navigation bar hidden.

  1. Set theme style:
    Add the following attribute in the Activity tag in the AndroidManifest.xml file.
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

This will put the Activity into full-screen mode, hiding both the status bar and navigation bar.

  1. Implementing Immersive Mode in Activity can hide the status and navigation bars, allowing users to show them by simply swiping the screen. To enable Immersive Mode, add the following code in the onCreate() method of the Activity.
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_IMMERSIVE
        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_FULLSCREEN);

Here are some common methods to hide the status and navigation bars on an Android device. Choose the method that best suits the needs of your application to implement hiding.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds