Using Styles And Thems in Android

When designing your application, you can use styles and themes to apply uniform formatting to its various screens and UI elements.
  • A style is a set of one or more formatting attributes that you can apply as a unit to single elements in your layout XML file(s). For example, you could define a style that specifies a certain text size and color, then apply it to instances of a certain type of View element.
  • A theme is a set of one or more formatting attributes that you can apply as a unit to all activities in an application or just a single activity. For example, you could define a theme that sets specific colors for the window frame and the panel foreground and background, and sets text sizes and colors for menus, then apply it to the activities of your application.
Styles and themes are resources. Android provides some default style and theme resources that you can use, or you can declare your owncustom style and theme resources.
To create custom styles and themes:
  1. Create a file named styles.xml in the your application's res/values directory. Add a root  node.
  2. For each style or theme, add a 


Style:-

Here's an example declaration of a style:

    

As shown, you can use  elements to set specific formatting values for the style. The name attribute in the item can refer to a standard string, a hex color value, or a reference to any other resource type.
Notice the parent attribute in the 
Post a Comment