How to hide navigation bar in Android app?

后端 未结 6 756
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 05:28

I was wondering how I could hide the navigation bar in an Android application?

I know how to hide it initially, but as soon as I touch the screen it pops back up. I

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 06:05

    Here it is in the context of the onCreate method:

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            this.getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
    
        }
    

    The Android docs have a good explanation of what the different flags do: Using Immersive Full-Screen Mode

提交回复
热议问题