Skip to the workspace
Pebellslearn by building
Building Screens with Jetpack Compose  ›  Lesson

Column, Row and Box

Column / Row 14 minColumn stacks children vertically, Row places them side by side, Box layers them on top of each other, and modifiers set size, padding and alignment.

android / Column, Row and Box

Explore each scene at your own pace.

01 · The rule

The rule

Column, Row and Box

Each row in Sprout's plant list has a photo, a name, a date, and a small "thirsty" badge on the photo's corner. Almost every screen you will ever build is some nesting of three layouts: Column, Row and Box.

The rule

Column goes down, Row goes across, Box stacks on top.

  • Column places children one below another.
  • Row places children side by side.
  • Box places children on top of each other, like layers; later children are drawn above earlier ones.
Row(modifier = Modifier.padding(16.dp)) {
    Box {
        Image(painter = photo, contentDescription = plant.name)
        ThirstyBadge(Modifier.align(Alignment.TopEnd))
    }
    Spacer(Modifier.width(12.dp))
    Column {
        Text(plant.name)
        Text("Water on ${plant.nextDate}")
    }
}

Modifiers adjust any composable: size (fillMaxWidth(), size(48.dp)), spacing (padding), looks (background), behaviour (clickable). They are applied in order, so the order changes the result: padding then background leaves an uncoloured gap outside the colour, while background then padding colours the gap too.

Alignment comes from the parent: Column takes horizontalAlignment, Row takes verticalAlignment, and a child in a Box uses Modifier.align(...).

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.