0Pricing
Jetpack Compose Academy · Lesson

Padding, Size & fillMaxWidth

Control space inside and around a Composable.

Padding, Size & fillMaxWidth is a free Jetpack Compose Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Jetpack Compose Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Meet the Modifier

A Modifier is how you adjust a Composable: its size, spacing, and decoration. You chain calls onto it, one tweak at a time. 🧩

Pass It In

Almost every Composable takes a modifier parameter. You pass it as the first thing to change about that element.

Text(
  text = "Hi",
  modifier = Modifier
)

Add Some Padding

Use padding to add empty space around a Composable. It pushes everything else away, giving your element room to breathe.

Text(
  "Hi",
  modifier = Modifier.padding(16.dp)
)

The dp Unit

Sizes use dp, density-independent pixels. They look the same on every screen, so 16.dp is consistent across phones and tablets.

Padding Per Side

You can pad each side differently. Pass horizontal and vertical, or name individual sides like start and top.

Modifier.padding(
  horizontal = 16.dp,
  vertical = 8.dp
)

Set a Fixed Size

Use size to give a Composable an exact width and height. One value makes it square; two values set each dimension.

Modifier.size(width = 120.dp, height = 48.dp)

Width and Height Alone

Need only one dimension? Use width or height on their own and let the other side wrap its content naturally.

Modifier.height(56.dp)

Fill the Width

fillMaxWidth stretches a Composable to take up all the horizontal space its parent offers. Great for full-width buttons and rows.

Modifier.fillMaxWidth()

Fill a Fraction

Pass a fraction to fill only part of the space. fillMaxWidth(0.5f) takes half the available width instead of all of it.

Modifier.fillMaxWidth(0.5f)

Fill Everything

Use fillMaxSize to expand in both directions at once. It is the shortcut for filling width and height together.

Modifier.fillMaxSize()

Chain Them Together

The real power is chaining: stack padding, size, and fill in one fluent call to shape an element exactly how you want.

Modifier
  .fillMaxWidth()
  .padding(16.dp)

Quick Check

Which modifier stretches a Composable across all the horizontal space its parent gives?

Recap

You learned to space, size, and stretch any Composable. padding adds room, size sets exact bounds, and fillMaxWidth grows to fit. ✨

Frequently asked questions

Is the “Padding, Size & fillMaxWidth” lesson free?

Yes — the full text of “Padding, Size & fillMaxWidth” is free to read here on the web, and the Jetpack Compose Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Jetpack Compose Academy course, upgrade to CoddyKit PRO.

What will I learn in “Padding, Size & fillMaxWidth”?

Control space inside and around a Composable. You practise Jetpack Compose Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Jetpack Compose Academy?

No prior experience is required. Jetpack Compose Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Padding, Size & fillMaxWidth” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Jetpack Compose Academy lesson?

Yes. Every Jetpack Compose Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Padding, Size & fillMaxWidth
  2. Background, Border & Clip
  3. Why Modifier Order Matters
  4. weight & Flexible Sizing
← Back to Jetpack Compose Academy