Theme inheritancesuggest change
When defining themes, one usually uses the theme provided by the system, and then changes modifies the look to fit his own application. For example, this is how the
Theme.AppCompat theme is inherited:
<style name="AppTheme" parent="Theme.AppCompat"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style>
This theme now has all the properties of the standard
Theme.AppCompat theme, except the ones we explicitly changed.
There is also a shortcut when inheriting, usually used when one inherits from his own theme:
<style name="AppTheme.Red"> <item name="colorAccent">@color/red</item> </style>
Since it already has
AppTheme. in the start of it’s name, it automatically inherits it, without needing to define the
parent theme. This is useful when you need to create specific styles for a part (for example, a single Activity) of your app.
Found a mistake? Have a question or improvement idea? Let me know.
Table Of Contents