David Adeyinka
1 min readJan 13, 2023

--

My Learnings on Styles and Themes in Android — part 2

This part will be a brief coverage of the usage of XML-based styles and themes in Android.

Styles and Themes

In terms of structure, styles and themes are the same thing in Android — they’re a set of property-value mappings with defined in the style element. The only difference between them is that styles apply to individual views while themes apply to view hierarchies, including ViewGroups and Activities. Style elements act as styles when the style attribute is used and as themes when the theme attribute is used.

Material Design theme

There are three main aspects to the theme — color, typography, and shape. I’ll only talk about color here.

Color in Material Design consists of a set of named values that are given a semantic name in the theme — these include the colorPrimary, colorSecondary, and so on. It’s expected to use these special names when specifying colors on UI elements to act as an abstraction from the actual values being used , similar to an interface in Java — it makes changing colors easier in the future.

Conclusion

This article was rather brief, but next week I will cover everything in better detail. Thank you for reading, and I want you to keep on learning.

--

--