Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the soft navigation bar(virtual buttons) of android device for whole application?

Tags:

android

I want to hide the soft navigational bar i.e. virtual buttons of android device for whole app. I have used below code snippet

getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_IMMERSIVE
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

to hide it but when i slide gridview it will become visible .

like image 537
Sharanjeet Kaur Avatar asked Nov 28 '16 07:11

Sharanjeet Kaur


2 Answers

Immersive flag for setSystemUiVisibility() lets your app go truly "full screen." Link

Try below code, for immersive mode.

@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
    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);
}
}
like image 186
Rahul Avatar answered Sep 22 '22 08:09

Rahul


View decorView = getWindow().getDecorView();

// Hide both the navigation bar and the status bar.

int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
like image 25
Sharanjeet Kaur Avatar answered Sep 22 '22 08:09

Sharanjeet Kaur