首页 > 技术文章 > Android AppTheme 系統預設樣式android:Theme語法整理

ericyuan 2013-09-28 22:57 原文

在使用新版Eclipse開發Android程式時

創建Android Project後會多了res/values/styles.xml的樣式檔案

事實上這是讓Android讀取的預設的樣式定義檔

例如要讓整個程式的基本樣式為亮色系或暗色系~

或者要隱藏標題全螢幕等等, 皆可以在這個檔案上進行修改...

 

而相關語法參數如下

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Light.NoTitleBar"  //直接更改这个值或者参考方法二   
>

 

方法二:更改/res/values/目錄下, styles.xml的內容

<resources>
  <style name="AppTheme" parent="android:Theme.Light" />
</resources>

 

android:theme="Theme.Light" 背景為白色

android:theme="Theme.Light.NoTitleBar" 白色背景並無標題欄 

android:theme="Theme.Light.NoTitleBar.Fullscreen"白色背景,無標題欄,全螢幕

android:theme="Theme.Black" 背景黑色

android:theme="Theme.Black.NoTitleBar" 黑色背景並無標題欄

android:theme="Theme.Black.NoTitleBar.Fullscreen"黑色背景,無標題欄,全螢幕

android:theme="Theme.Wallpaper" 用系統桌面為應用程式背景

android:theme="Theme.Wallpaper.NoTitleBar" 用系統桌面為應用程式背景,且無標題欄

android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen"  用系統桌面為應用程式背景,無標題欄,全螢幕

android:theme="Translucent"

android:theme="Theme.Translucent.NoTitleBar"

android:theme="Theme.Translucent.NoTitleBar.Fullscreen"

android:theme="Theme.Panel"

android:theme="Theme.Light.Panel"

android:theme="@android:style/Theme.Dialog" 將一個Activity顯示為能話框模式

android:theme="@android:style/Theme.NoTitleBar"不顯示應用程式標題欄

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"不顯示應用程式標題欄,並全螢幕

 

推荐阅读