一、在代碼中設定
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去除title
requestWindowFeature(Window.FEATURE_NO_TITLE);
//去掉Activity上面的狀態列
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
或者
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
R.layout.custom_title_1 這個就是你的標題檔案布局
二、在設定檔裡修改
(關鍵代碼:android:theme="@android:style/Theme.NoTitleBar.Fullscreen",如果想只是去除標題列就後面不用加Fullscreen了,另外,如果想要整個應用都去除標題列和狀態列,就把這句代碼加到<application。。標籤裡面,如果只是想某個activity起作用,這句代碼就加到相應的activity上):
隱藏標題列需要使用預定義樣式:android:theme=”@android:style/Theme.NoTitleBar”.
隱藏狀態列:android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”.
在這裡我還想說明一下,用前者在我們應用運行後,會看到短暫的狀態列,然後才全屏,而第二種方法是不會有這種情況的,所以我建議大家使用後者!