A style is a collections of properties that specify the look and format of a view or window.
They allow to separate the design from the content.
Without Style XML, we can design it in the Layout XML:
With Style XML, we can turn it to:
A theme is a style applied to an entire Activity of Application, rather than an individual view.
When a style is applied as a theme, every View in the Activity or application will apply each style property that it supports.
Then add an <item> element for each property of that style, with a name that declares the style property and a value to go with it.
Defining Styles
The root node of the XML file must be <resources>.
For each style you want to create, add a <style> element to the file with a name that uniquely identifies the style.
Each child of the <resource> element is converted into an application resource object at compile-time.
Example:
Inheritance
The parent attribute in the
Example
Style properties
The best place to find properties that apply to a specific View is the corresponding class reference, which lists all of the supported attributes.
Example
↳android.R.attr
public static final int textColor
Added in
Color of text (usually same as colorForeground).
May be a reference to another resource, in the form "@[+][package:]type:name
" or to a theme attribute in the form "?[package:][type:]name
".
May be a color value, in the form of "#rgb
", "#argb
", "#rrggbb
", or "#aarrggbb
".
Constant Value: 16842904 (0x01010098)