標籤:data nbsp data- post 範圍 ace 程式 man article
主題Theme就是用來設定介面UI風格,可以設定整個應用或者某個活動Activity的介面風格。在Android SDK中內建了下面的Theme,可以按標題列Title Bar和狀態列Status Bar是否可見來分類:
[html] view plain copy print?
- •android:theme="@android:style/Theme.Dialog" 將一個Activity顯示為能話框模式
- •android:theme="@android:style/Theme.NoTitleBar" 不顯示應用程式標題欄
- •android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應用程式標題欄,並全屏
- •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"
這些主題可以應用到整個應用Application範圍或者某個活動Activity範圍中。
應用Application範圍
在AndroidManifest.xml中的application節點中設定theme屬性,主題theme應用到整個應用程式中。
<application
android:icon=”@drawable/icon”
Android:icon=”@string/app_name”
Android:icon=”@android:style/ Theme.Black.NoTitleBar”>
活動Activity範圍
使用Java代碼或者在AndroidManifest.xml中對活動Activity的主題進行設定,主題僅應用到當前活動中。
在AndroidMainifest.xml設定方法:
<activity
android:name=“.About”
android:label=“@string/app_name”
android:theme=“@android:style/ Theme.Black.NoTitleBar” >
使用java代碼進行設定,在當前活動Activity的onCreate中進行設定:
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setTheme(android.R.style.Theme_Translucent_NoTitleBar);
setContentView(R.layout.main);
}
@android:style/Theme.Black //背景黑色-有標題-非全屏
@android:style/Theme.Black.NoTitleBar //背景黑色-無標題-非全屏 @android:style/Theme.Black.NoTitleBar.Fullscreen //背景黑色-無標題-全螢幕顯示 @android:style/Theme.Dialog //對話方塊顯示 @android:style/Theme.InputMethod @android:style/Theme.Light //背景白色-有標題-非全屏 @android:style/Theme.Light.NoTitleBar //背景白色-無標題-非全屏 @android:style/Theme.Light.NoTitleBar.Fullscreen //背景白色-無標題-全螢幕顯示 @android:style/Theme.Light.Panel @android:style/Theme.Light.WallpaperSettings //背景透明 @android:style/Theme.NoDisplay @android:style/Theme.Translucent.NoTitleBar.Fullscreen //半透明、無標題列、全屏 @android:style/Theme.Wallpaper.NoTitleBar.Fullscreen
Android 主題theme說明 摘記