Android Theme詳細內容概述

來源:互聯網
上載者:User

Android手機作業系統是一個開源的作業系統。其應用方式靈活方便,極受廣大編程人員的喜愛。我們在這裡就可以先來瞭解一下Android Theme的具體用法。Android Theme的用法與style的差不多,不過,具體還是有些不一樣的

首先在values下建立一個theme.xml,用來定義需要的theme了,代碼如下:

Xml代碼

 
  1. < ?xml version="1.0" encoding="utf-8"?>   
  2. < resources>   
  3. < style name="theme" parent="android:Theme.Black">   
  4. < item name="android:windowNoTitle">true< /item>   
  5. < item name="android:textSize">14sp< /item>   
  6. < item name="android:textColor">#FFFF0000< /item>   
  7. < /style>   
  8. < /resources>   
  9. < ?xml version="1.0" encoding="utf-8"?> 
  10. < resources> 
  11. < style name="theme" parent="android:Theme.Black"> 
  12. < item name="android:windowNoTitle">true< /item> 
  13. < item name="android:textSize">14sp< /item> 
  14. < item name="android:textColor">#FFFF0000< /item> 
  15. < /style> 
  16. < /resources> 

Android Theme的用法是不是跟style的很相似?

然後你可以在需要的那個activity上引用,加上

Java代碼

 
  1. setTheme(R.style.theme);   
  2. setTheme(R.style.theme);  

這句代碼就ok了。

當然,你也可以在AndroidManifest.xml中定義把主題運用到整個application或者具體的activity中,代碼:

Xml代碼

 
  1. < application android:icon="@drawable/icon" 
    android:label="@string/app_name"   
  2. android:theme="@style/theme">   
  3. < application android:icon="@drawable/icon" 
    android:label="@string/app_name" 
  4. android:theme="@style/theme"> 

在application屬性加上一句就可以了。如果你需要為特定的activity指定Android Theme,你只要把這句加到AndroidManifest.xml中activity中的屬性就ok。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.