
The style will inherit the properties from TextviewStyle and TextviewStyle.Blue styles and it will add a new android:background attribute.

The newly created style referenced from Textview as can continue inheriting the styles like this as many times by chaining names with periods.įollowing is the example to extend Textviewstyle.Blue style to further. The TextviewStyle.Blue style will inherit all the properties from TextviewStyle and overrides the android:textColor and android:textStyle attributes to make the text italic and Blue. If you observe above code snippet, we didn’t used any parent attribute in tag, we used style name TextviewStyle to inherit all the style attributes. In android, we can define multiple styles using element with a name attribute to uniquely identify the style in an XML file.įollowing is the example of defining a style in separate XML file using element.

In case if we use an entry from a resource file to style activity or app, then we can call it a theme.

In simple words, if we use an entry from a resource file to style a view, then we can call it a style. If we apply TextviewStyle as a theme for an activity, then the text of all the views in activity appears in the same style. When we applied a style as a theme, the views in activity or app apply to the all style attributes that supports. In android, theme is a style that is applied to an entire activity or app, instead of an individual View like as mentioned above. In following sections we will see the definition of TextviewStyle attribute. If you observe above code snippet, we removed all style attributes from XML layout and moved those attributes to a style definition called TextviewStyle.
