Android: Disable and enable to pulling the status bar programmatically for API 19

前端 未结 2 447
傲寒
傲寒 2021-01-07 13:44

I already done do to hide the status bar, but unfortunately I didn\'t found the way to display it back once its already hide. I did so many workaround but still not success,

2条回答
  •  一整个雨季
    2021-01-07 14:39

    For Hiding Status Bar on 4.1 or Higher use

    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    // Remember that you should never show the action bar if the
    // status bar is hidden, so hide that too if necessary.
    ActionBar actionBar = getActionBar();
    actionBar.hide();
    

    OR

    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    

    To make Status Bar Visible

    View decorView = getWindow().getDecorView();
    // Hide the status bar.
    int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
    decorView.setSystemUiVisibility(uiOptions);
    // Remember that you should never show the action bar if the
    // status bar is hidden, so hide that too if necessary.
    ActionBar actionBar = getActionBar();
    actionBar.show();
    

    OR

    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); 
    

    Refer Immersve View

    android Exit from full screen mode

提交回复
热议问题