五行代码搞定沉浸式状态栏适用于21及以上版本

 /**
     * 沉浸式模式
     */
    private void hideActionBar() {
        //沉浸式隐藏状态栏
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            getWindow().setStatusBarColor(Color.TRANSPARENT);//透明色
        }
        //隐藏标题栏
        getSupportActionBar().hide();
        Loging.e("--------------------隐藏状态栏");
    }

你可能感兴趣的:(五行代码搞定沉浸式状态栏适用于21及以上版本)