Tuesday, September 6, 2011

Theme

Theme is some style elements can be applied across an entire activity, or application.



Android OS provide a number of pre-build Theme for you in Android SDK; for example: you can open the file below, you can find a number of pre-build theme start with "Theme.".



/android-sdk-linux_x86/platforms/android-8/data/res/values/themes.xml



such as:
  • Theme.NoTitleBar

  • Theme.NoTitleBar.Fullscreen

  • Theme.Light

  • Theme.Light.NoTitleBar

  • Theme.Light.NoTitleBar.Fullscreen

  • ...



To apply Theme on activity (or on whole application), you can add attribute of "android:theme=..." in AndroidManifest.xml, under <activity> (or <application>).



example of android:style/Theme.Panel:

android:style/Theme.Panel

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exercise.AndroidTheme"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@android:style/Theme.Panel">
<activity android:name=".AndroidThemeActivity"
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>
</manifest>




1 comment: