Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
CompositionLocal
In this chapter, you have seen a few examples where nesting one composable inside another causes the inner composable’s appearance to change. Using the MaterialTheme composable, for example, causes all components nested within it to be aware of your theme and use its colors.
When you added the Text to your TopAppBar, you might have noticed something interesting. Despite the fact that you did not specify any parameters besides the text itself, the Text was appropriately styled with the correct font size and color to appear in your app bar. How did this happen?
When you build a UI using Jetpack Compose, a composition hierarchy is created at runtime for all your composables – much like the view hierarchy for framework ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access