Prevent StatusBar from showing when using AlertDialog.Builder

前端 未结 5 862
半阙折子戏
半阙折子戏 2021-01-22 10:34

In the XML of my MainActivity, I have programmed it so that it uses a theme with NoActionBar and therefore there is no ac

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-22 11:18

    Latest Working Example

    The accepted answer works only for API Level 16 or lower. In newer versions, for AlertDialog do the following:

    if (Build.VERSION.SDK_INT < 16) {
        alert.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else {
        View decorView = alert.getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
    }
    

提交回复
热议问题