tezvyn:

Styles vs. Themes and Attribute Resolution in Android

Source: developer.android.comintermediate

This tests your grasp of Android's resource indirection. A Style is a set of attributes for one View type. A Theme is a collection of named attributes for an app or Activity. `?attr` is resolved at runtime against the Theme, while `@color` is a direct.

This question tests your deep understanding of Android's resource system, particularly the powerful indirection mechanism of themes. A great answer distinguishes a Style (attributes for a specific View type) from a Theme (a named map of attributes for an app/Activity). Then, it explains that `?attr/colorPrimary` is a runtime lookup against the current Theme, while `@color/purple_500` is a direct reference resolved at compile time. The key red flag is treating themes and styles as interchangeable.

Read the original → developer.android.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Styles vs. Themes and Attribute Resolution in Android · Tezvyn