How to hide status bar?

后端 未结 5 1853
广开言路
广开言路 2021-01-17 11:59

How can I hide the status bar for a specific activity?

I found this similar question, but none of the answers worked for me. The app just crashed every time I tried

5条回答
  •  既然无缘
    2021-01-17 12:24

    if (Build.VERSION.SDK_INT < 16)//before Jelly Bean Versions
    { 
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    else // Jelly Bean and up
    { 
        View decorView = getWindow().getDecorView();
        // Hide the status bar.
        int ui = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(ui);
    
        //Hide actionbar
        ActionBar actionBar = getActionBar();
        actionBar.hide();
    }
    

提交回复
热议问题