android - 如何隐藏状态栏

时间:2012-06-14 07:46:55

标签: android android-titlebar

我在manifeast文件的应用程序标记中设置了以下属性。但它隐藏了标题栏(Actionbar)和状态栏。我想隐藏状态栏。

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

3 个答案:

答案 0 :(得分:2)

仅隐藏状态栏将此代码添加到oncreate of activity中:

// Hide the Status Bar
 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
 
WindowManager.LayoutParams.FLAG_FULLSCREEN);

并从清单

中删除android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

答案 1 :(得分:1)

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

将此代码添加到您的活动开头

答案 2 :(得分:1)

请尝试以下代码段:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

     /* add below 2 lines*/
    getWindow().clearFlags(android.view.WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
}