標籤:android style blog http color 使用 io strong
先介紹去掉標題列的方法:
第一種:也一般入門的時候經常使用的一種方法
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">
這樣也可以達到去掉標題列的效果
三種去掉標題列方法的總結
第一種,有的時候我們會看到,會先出現標題列,然後再消失,因為我們只是在activity的oncreate方法中定義的,第二種相對第一種比較好一些,不會出現這種情況,第三種我個人感覺最好,這樣把功能分開,便於維護和擴充
再介紹全屏的方法
第一種:
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" />
來源:Android中全屏或者取消標題列