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
- < ?xml version="1.0" encoding="utf-8"?>
- < resources>
- < style name="theme" parent="android:Theme.Black">
- < item name="android:windowNoTitle">true< /item>
- < item name="android:textSize">14sp< /item>
- < item name="android:textColor">#FFFF0000< /item>
- < /style>
- < /resources>
- < ?xml version="1.0" encoding="utf-8"?>
- < resources>
- < style name="theme" parent="android:Theme.Black">
- < item name="android:windowNoTitle">true< /item>
- < item name="android:textSize">14sp< /item>
- < item name="android:textColor">#FFFF0000< /item>
- < /style>
- < /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
- setTheme(R.style.theme);
- 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
- < application android:icon="@drawable/icon"
android:label="@string/app_name"
- android:theme="@style/theme">
- < application android:icon="@drawable/icon"
android:label="@string/app_name"
- 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.