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