Android隐藏状态栏,兼容性

时间:2014-02-09 15:38:56

标签: java android statusbar android-4.2-jelly-bean

我有以下代码来隐藏从http://developer.android.com/training/system-ui/status.htmlHide status bar android

中取得的状态栏
    //hide statut bar
    if (Build.VERSION.SDK_INT < 16) { //ye olde method
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    } else { // Jellybean and up, new hotness
        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();
    }

我在View.SYSTEM_UI_FLAG_FULLSCREEN;

上收到错误

似乎SYSTEM_UI_FLAG_FULLSCREEN在View中不再存在。

如何解决?谢谢你

1 个答案:

答案 0 :(得分:1)

自API16起存在。您必须针对API16(或更高版本)

构建您的应用