Android 主題theme說明 摘記

來源:互聯網
上載者:User

標籤:data   nbsp   data-   post   範圍   ace   程式   man   article   

主題Theme就是用來設定介面UI風格,可以設定整個應用或者某個活動Activity的介面風格。在Android SDK中內建了下面的Theme,可以按標題列Title Bar和狀態列Status Bar是否可見來分類:

 


 

[html] view plain copy print?
  1. •android:theme="@android:style/Theme.Dialog"   將一個Activity顯示為能話框模式  
  2. •android:theme="@android:style/Theme.NoTitleBar"  不顯示應用程式標題欄  
  3. •android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  不顯示應用程式標題欄,並全屏  
  4. •android:theme="Theme.Light"  背景為白色  
  5. •android:theme="Theme.Light.NoTitleBar"  白色背景並無標題列   
  6. •android:theme="Theme.Light.NoTitleBar.Fullscreen"  白色背景,無標題列,全屏  
  7. •android:theme="Theme.Black"  背景黑色  
  8. •android:theme="Theme.Black.NoTitleBar"  黑色背景並無標題列  
  9. •android:theme="Theme.Black.NoTitleBar.Fullscreen"    黑色背景,無標題列,全屏  
  10. •android:theme="Theme.Wallpaper"  用系統案頭為應用程式背景  
  11. •android:theme="Theme.Wallpaper.NoTitleBar"  用系統案頭為應用程式背景,且無標題列  
  12. •android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen"  用系統案頭為應用程式背景,無標題列,全屏  
  13. •android:theme="Translucent"  半透明  
  14. •android:theme="Theme.Translucent.NoTitleBar" 半透明、無標題列  
  15. •android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 半透明、無標題列、全屏  
  16. •android:theme="Theme.Panel"  
  17. •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說明 摘記

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.