一、去掉標題欄的方法
第一種:入門的時候經常使用的一種方法
requestWindowFeature(Window.FEATURE_NO_TITLE);
//去掉標題欄注意這句一定要寫在setContentView()方法的前面,不然會報錯的
第二種:在AndroidManifest.xml文件中定義
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
可以看出,這樣寫的話,整個應用都會去掉標題欄,如果只想去掉某一個Activity的標題欄的話,可以把這個屬性加到activity標簽里面第三種:這種在一般的應用中不常用,就是在res/values目錄下面新建一個style.xml的文件
例如:
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="notitle">
<item name="android:windowNoTitle">
true
</item>
</style>
</resources>
這樣,我們就自定義了一個style,就相當于一個主題,然后在AndroidManifest.xml文件中定義,也可達到去掉標題欄的效果
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/notitle">
二、介紹全屏的方法
第一種
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
第二種
<android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
第三種
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/fullscreem">