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 ...
Get Android Programming: The Big Nerd Ranch Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.