Stage 2 · Lesson 3 of 10
Modifiers and why their order matters
A changes how a looks or behaves: size, padding, background, border, click handling, scrolling and more. Modifiers are chained and applied in order, from the outside in. So Modifier.padding(16.dp).background(Color.Red) leaves a gap around a red area.
Put background before padding and the padding is coloured too. The same goes for clickable: put it before padding and the whole padded area can be tapped. By convention every reusable composable takes a modifier parameter with a default of Modifier, and applies it to its outermost element. That lets callers position it.
Common trapforgetting that parameter, which makes a component impossible to size or space from the outside.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with
- CourseFreeAndroid Basics with Compose
Google · Beginner
Units 2 and 3: Compose layouts, state, scrollable lists and Material theming