Using new IMMERSIVE mode in android kitkat

后端 未结 6 707
说谎
说谎 2020-12-14 01:56

I want to make an activity to go into IMMERSIVE mode and hide top and buttom system bars as soon as it starts.

In developers site of android they say I should use

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 02:46

    Get the decor view:

    getWindow().getDecorView().setSystemUiVisibility(...)
    

    Remember that the arguments are bit flags. Only call the method above once:

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

提交回复
热议问题