如何隐藏状态栏?

问题描述:

如何隐藏特定活动的状态栏?如何隐藏状态栏?

我发现了这个类似的问题,但没有答案为我工作。该应用程序刚刚坠毁,每次我试图去活动: How to hide status bar in Android

谢谢。

+0

http://*.com/questions/33692388/android-remove-actionbar-title-keeping-toolbar-menu/33692402#33692402 –

+0

状态栏就是我想要去除,不行动起来吧。 – user5495265

设置你的内容之前,试试这个在您的活动

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
+0

这工作,但它适用于所有版本的Android? – user5495265

+0

是的,它会适用于所有版本的Android –

隐藏在Android 4.0的状态栏和下

  1. 通过设置应用程序的主题中manifest.xml文件。

    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" 
    

    OR

  2. 通过活动的onCreate()方法编写Java代码。

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        // If the Android version is lower than Jellybean, use this call to hide 
        // the status bar. 
        if (Build.VERSION.SDK_INT < 16) { 
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
           WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        } 
        setContentView(R.layout.activity_main); 
    } 
    

隐藏在Android 4.1的状态栏和更高

通过活动的onCreate()方法编写Java代码。

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

if (Build.VERSION.SDK_INT < 16)//before Jelly Bean Versions 
{ 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
         WindowManager.LayoutParams.FLAG_FULLSCREEN); 
} 
else // Jelly Bean and up 
{ 
    View decorView = getWindow().getDecorView(); 
    // Hide the status bar. 
    int ui = View.SYSTEM_UI_FLAG_FULLSCREEN; 
    decorView.setSystemUiVisibility(ui); 

    //Hide actionbar 
    ActionBar actionBar = getActionBar(); 
    actionBar.hide(); 
}