
By abstracting the resource with a theme, we can provide different concrete values (such as colorPrimary=orange) in different themes. In the example above the colorPrimary attribute specifies that the primary color for this theme is teal. A theme provides concrete values for these named resources. Theme attributes are different from view attributes because they’re not properties specific to an individual view type but semantically named pointers to values which are applicable more broadly in an app. These named resources are known as theme attributes, so a theme is Map. Styles are a collection of view attributes specific to a single type of widget Styles are specific to a single type of widget because different widgets support different sets of attributes: attributes that a widget declares and you might set in a layout file. That is the keys are all view attributes i.e. What’s in a style?Ī style is a collection of view attribute values. You can think of both as key-value stores where the keys are attributes and the values are resources. Theme != Styleīoth themes and styles use the same syntax but serve very different purposes. In this first article, I’ll take a look at the building blocks of the styling system: themes and styles.

This is the first in a series of articles where Chris Banes and I will set out to demystify Android styling so that you can make stylish apps without pulling your hair out. Proper use of it can make themes and styles easier to maintain, make branding updates less scary and make it straightforward to support dark modes. The Android styling system offers a powerful way to specify your app’s visual design, but it can be easy to misuse.
