import android.view.Window; import android.view.WindowManager;/** * 隐藏状态栏 */ private void hideStatusBar() { //定义全屏参数 int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN; //获得窗口对象 Window myWindow = this.getWindow(); //设置Flag标识 myWindow.setFlags(flag, flag); }
在启动的MainActivity contentView之前调用一下即可,
//隐藏状态栏 this.hideStatusBar(); setContentView(R.layout.activity_main);