Introduction
Use an Android Theme
-
Theme.Holo for "dark" theme
This is the default theme with a higher preference than the Holo theme. This theme was first added in API level 11. However, this theme is good because anyone can count the text as text that must be light on the dark background. Although we must not make any assumptions of it.If we are developing for the API level 11 or the higher versions of Android then we must implement the theme Holo or Theme_DeviceDefault. If we are developing for the Honeycomb version of Android then the widgets in the holographic theme are translucent on their background, so applications must ensure that any background they use with this theme is itself dark; otherwise, it will be difficult to see the widgets. Basically this User Interface style also includes a full Action Bar by default ("public static final int Theme_Holo ").
-
Theme.Holo.Light for a "light" theme
This theme has a light background with dark text. This theme is just for the Android version API level 11. However in the honeycomb version the holographic theme (light version). The widgets in the holographic theme are translucent on their background, so applications must ensure that any background they use with this theme is itself light. Otherwise, it will be difficult to see the widgets. This User Interface style also includes a full Action Bar by default (985).
For example
- <application android: theme ="@android:style/Theme.Holo.light.../>
When Using Support Library
- Theme.AppCompat for the dark theme.
- Theme.AppCompat.Light for the "light" theme.
- Theme.AppCompat.Light.DarkActionBar
Likewise, CSS in web design and styles in Android plays same role. However, both are used for design purposes but the syntax is different.
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textColor="#00FF00"
- android:typeface="monospace"
- android:text="@string/hello" />
It can be rewritten as,
- <TextView
- style="@style/CodeFont"
- android:text="@string/hello" />
Defining the Styles
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <style name="CodeFont" parent="@android:style/TextAppearance.Medium">
- <item name="android:layout_width">fill_parent</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:textColor">#00FF00</item>
- <item name="android:typeface">monospace</item>
- </style>
- </resources>
Style Properties
- <Edit Text
- android: inputType="number"
- ....../>
We can instead create a style for the EditText element that includes this property:
- <style name="Numbers">
- <item name="android:inputType">number</item>
- ...
- </style>
Customizing the Background
For Android 3.0 and higher only
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <!-- the theme applied to the application or activity -->
- <style name="CustomActionBarTheme"
- parent="@android:style/Theme.Holo.Light.DarkActionBar">
- <item name="android:actionBarStyle">@style/MyActionBar</item>
- </style>
- <!-- ActionBar styles -->
- <style name="MyActionBar"
- parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
- <item name="android:background">@drawable/actionbar_background</item>
- </style>
- </resources>
Then apply the theme to the entire application or individual activities as in the following:
- <application android:theme="@style/CustomActionBarTheme" ... />
For Android 2.1 and higher
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <!-- the theme applied to the application or activity -->
- <style name="CustomActionBarTheme"
- parent="@style/Theme.AppCompat.Light.DarkActionBar">
- <item name="android:actionBarStyle">@style/MyActionBar</item>
- <!-- Support library compatibility -->
- <item name="actionBarStyle">@style/MyActionBar</item>
- </style>
- <!-- ActionBar styles -->
- <style name="MyActionBar"
- parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
- <item name="android:background">@drawable/actionbar_background</item>
- <!-- Support library compatibility -->
- <item name="background">@drawable/actionbar_background</item>
- </style>
- </resources>
Then apply this theme to the entire app or individual activities:
- <application android:theme="@style/CustomActionBarTheme" ... />
- <item name="actionBarStyle">@style/MyActionBar</item>
- <item name="background">@drawable/actionbar_background</item>

Neeraj KumarPosted Jul 30, 2015, 4:25 PM
Nice Article