Android Theme details

Source: Internet
Author: User

The Android mobile operating system is an open-source operating system. Its application method is flexible and convenient, and is very popular with the majority of programmers. Here we can first learn about the specific usage of Android Theme. The usage of Android Theme is similar to that of style. However, it is still somewhat different.

Create a theme. xml file under values to define the theme. The Code is as follows:

Xml Code

 
 
  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> 

Is the usage of Android Theme similar to that of style?

Then you can reference it on the desired activity, and add

Java code

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

The code is OK.

Of course, you can also define in AndroidManifest. xml to apply the topic to the entire application or specific activity. The Code is as follows:

Xml Code

 
 
  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"> 

Add a sentence to the application attribute. If you need to specify Android Theme for a specific activity, you only need to add this sentence to the property of activity in AndroidManifest. xml.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.