在setContentView();前加上下面代碼。
示例:
//隱藏標題欄,需要放在setContentView之前
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
//隱藏ActionBar
getSupportActionBar().hide();
去掉標題框的方法2:
將Activity的OnCreate類改爲繼承Activity。
然後將清單文件的該Activity中加入下面的屬性。
<theme="@android:style/Theme.NotitleBar.Fullscreen">