In androidmanifest. XML, you can define the topic of the entire app or the topic of a single activity. The following example defines a topic for the application and activity respectively:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" <application android:theme="custom_application_theme" <activity android:name=".Activity"android:theme="custom_activity_theme"/> </application></manifest>
The next question is to define your own theme. In fact, theme is just a style set with a wider scope, therefore, the format of theme and style is the same. If you use eclipse to create a blank project of more than 4.0, you can see the following androidmanifest. xml:
<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.yg.xesam.net.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
View the content of @ style/apptheme to see the final style definition (the system themes file is placed in/RES/values/themes. xml of the SDK platform ).
Custom theme can be defined in styles. xml. For convenience, you can also define themes. XML as follows:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="custom_application_theme" parent="android:Theme.Light"></style> <style name="custom_activity_theme" parent="custom_application_theme"></style></resources>
For details, refer to the themes. xml file that comes with the SDK. For example, you can define the full screen of the program and whether there is a title bar based on inheriting the parent (Android: theme. Light) style.
In the following example:
Custom_application_theme has no title bar and is full screen. custom_activity_theme overwrites the Android: windownotitle attribute of custom_application_theme. Therefore, custom_activity_theme is full screen but the title bar is retained.
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="custom_application_theme" parent="android:Theme.Light"> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> </style> <style name="custom_activity_theme" parent="custom_application_theme"> <item name="android:windowNoTitle">false</item> </style></resources>