How can I hide the Navigation bar (Back, Home, End Session) while my application is visible?

How can I hide the Navigation bar (Back, Home, End Session) while my application is visible?

Andrew Pierce
Add the following method to

Add the following method to your Activity and invoke from onResume.


The only part different from normal Android is the addition of the flag 0x4 that tells the OS to keep the navigation bar hidden.


private void setFullScreen(final boolean fullscreen) {

        // Hide/show the system bar

        Window window = getWindow();

        window.setFlags(fullscreen ?

                WindowManager.LayoutParams.FLAG_FULLSCREEN : 0,

                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        if (fullscreen) {

            // Keep the system bar hidden in full screen mode

            window.getDecorView().setOnSystemUiVisibilityChangeListener(new OnSystemUiVisibilityChangeListener() {

                @Override

                public void onSystemUiVisibilityChange(int visibility) {

                    if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0) {

                        getWindow().setFlags(

                                WindowManager.LayoutParams.FLAG_FULLSCREEN,

                                WindowManager.LayoutParams.FLAG_FULLSCREEN);

                    }

                    else {

                        getWindow().getDecorView().setSystemUiVisibility(

                                View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | 0x4);

                    }

                }

            });

        }

        else {

            window.getDecorView().setOnSystemUiVisibilityChangeListener(null);

        }

        window.getDecorView().setSystemUiVisibility(

                fullscreen ? (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | 0x4) : 0);

    }

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Adel Sari
Good job Andrew, this answer

Good job Andrew, this answer my question

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments