Spacing with Padding
Use Modifier for spacing.
What Is Padding?
Padding is empty space added around a composable's content. It pushes content away from the edges so things do not feel cramped.
In Compose you add padding through a Modifier.
Text(
text = "Hello",
modifier = Modifier.padding(16.dp)
)The dp Unit
Padding sizes use dp, short for density-independent pixels. dp looks the same physical size on every screen.
Write a number then .dp, such as 8.dp or 24.dp.
Modifier.padding(8.dp)All lessons in this course
- Styling Text
- Buttons and Clicks
- Spacing with Padding
- Colors and MaterialTheme