A theme can be used to apply uniform formatting and styles to your whole application, or to certain activities in your application. Creating themes is very similar to creating styles for your Android application; the only difference is that you can apply styles to view elements, while you can apply themes to your whole application or a set of activities. It is analogous to the CSS styles you apply to your web pages. Using custom themes can give your application a great look and help to differentiate it from the scores of other applications out there.
To create a custom theme, first of all, create a file named styles.xml and copy it to your application’s res/values directory.
Edit the styles.xml file and add a root node - . All your theme elements will be nested in the nodes.
Now to specify the style of the theme, just add a element inside which you can specify all your item styles. The element has a single attribute -
name - which specifies the name of the theme
This is the basic structure of your theme. In the style element, you can use many item elements which define the look of each item.
The item tags have an attribute name which identifies the item to which the style is applied. The values are written inside the tags. You can also refer to previous item values and copy them by writing ?itemname instead of the value.
Here’s an example of the whole theme file:
Now that the theme is created, you can apply it to your application by editing the AndroidManifest.xml file of your application and adding the android:theme attribute to the application tag with its attribute as the theme’s name you specified earlier.
If you want to apply it to a single activity and not the whole application, edit the activity tag to add its attribute.