Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
The Compose Modifier
What about attributes like background color, margins, padding, and click listeners? In the framework view system, these attributes are inherited, making them accessible on every subclass of View. But composable functions do not have the luxury of inheritance.
Instead, Compose defines a separate type called Modifier where it defines general-purpose customizations that can be set on any composable. Modifiers can be chained and combined as desired. Between modifiers and a composable’s function parameters, you can perform all the customizations you have used so far with framework views.
To modify a composable, pass a Modifier into the composable’s modifier parameter. You can obtain an empty modifier to build on ...
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