可以使用以下代码将状态栏隐藏,在AndroidManifest.xml文件中添加下列代码:
    ...
 
然后在布局文件中添加以下代码:
 
最后在Activity类中加入以下代码:
@SuppressLint("ObsoleteSdkInt")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Hide Status Bar
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //Make Status Bar Color Transparent
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
        getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.colorPrimaryDark));
    }
}
@Override
protected void onResume() {
    super.onResume();
    //Hide Status Bar
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    //Hide Status Bar View
    findViewById(R.id.statusbar).setVisibility(View.GONE);
}