Layouts: Column, Row, Box and Arrangement
The Three Basic Layouts
| Layout | Direction |
|---|---|
Column | Top to bottom |
Row | Start to end |
Box | Layers on top of each other |
kotlin
Column(
verticalArrangement = Arrangement.spacedBy(12.dp),
horizontalAlignment = Alignment.Start
) {
Text("Title", style = MaterialTheme.typography.titleLarge)
Text("Subtitle", color = Color.Gray)
}
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
Icon(Icons.Default.Person, contentDescription = null)
Text("Asha")
}
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(100.dp)) {
Box(Modifier.fillMaxSize().background(Color.Blue))
Text("On top", color = Color.White)
}
Simple example: Column is a stack of plates, Row is books standing side by side and Box is papers laid on top of one another.
Arrangement vs Alignment
| Concept | Controls | Examples |
|---|---|---|
Arrangement | Position along the main axis | SpaceBetween, Center, spacedBy(8.dp) |
Alignment | Position on the cross axis | CenterHorizontally, Top, End |
weight and Spacer
kotlin
Row(Modifier.fillMaxWidth()) {
Text("Name", Modifier.weight(1f)) // takes the remaining space
Text("Asha")
}
Column {
Text("Top")
Spacer(Modifier.weight(1f)) // pushes next item down
Text("Bottom")
}
Spacer(Modifier.height(16.dp)) // fixed gap
Profile Card Example
kotlin
@Composable
fun ProfileCard(name: String, role: String, modifier: Modifier = Modifier) {
Card(modifier = modifier.fillMaxWidth().padding(16.dp)) {
Row(
modifier = Modifier.padding(16.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
Icon(
Icons.Default.AccountCircle,
contentDescription = null,
modifier = Modifier.size(56.dp),
tint = MaterialTheme.colorScheme.primary
)
Column(Modifier.weight(1f)) {
Text(name, style = MaterialTheme.typography.titleMedium)
Text(role, style = MaterialTheme.typography.bodyMedium, color = Color.Gray)
}
Icon(Icons.Default.ChevronRight, contentDescription = null)
}
}
}
@Preview(showBackground = true)
@Composable
fun ProfileCardPreview() = ProfileCard("Asha Patel", "Android Developer")
FlowRow
kotlin
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
listOf("Kotlin", "Compose", "Room", "Hilt").forEach { tag ->
AssistChip(onClick = {}, label = { Text(tag) }) // wraps to the next line when full
}
}
Tip: Compose layouts are fast, and deep nesting is fine. You rarely need
ConstraintLayout in Compose, but it exists for complex screens.
Conclusion
Column, Row and Box are the base of every Compose screen. Master Arrangement, Alignment and weight.
Quick Summary: Column vertical, Row horizontal, Box layered. Arrangement sets main-axis spacing, Alignment sets cross-axis position and weight shares space.

