Search code examples
javaandroidstatusbar

Disable Statusbar and Navigationbar


my question is about enable/disable status bar and navigation bar in android,not just hiding it , but exactly disable it .

i used

setSystemUiVisibility() 

Function and its implementation just can hide status bar and navigation bar .

Is there anyway to disable/enable Statusbar and navigation bar ?

i searched a alot but not found anything usefull .

any suggestion is usefull , thanks .

here is the code that i tried :

 @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);
        }
    } 

and this is just hide the statusbar and navigation bar , and not disable status bar and navigation bar .


Solution

  • Try this line of the code for it above the setContentView()

     @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
        setContentView(R.layout.YOUR_LAYOUT)
    
    
    
    }