0Pricing
Jetpack Compose Academy · Aula

Preenchimento, Tamanho e fillMaxWidth

Controle o espaço dentro e ao redor de uma Composable.

Preenchimento, Tamanho e fillMaxWidth é uma aula grátis de Jetpack Compose Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Jetpack Compose Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Jetpack Compose Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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. ✨

Perguntas Frequentes

A aula “Preenchimento, Tamanho e fillMaxWidth” é grátis?

Sim — o texto completo de “Preenchimento, Tamanho e fillMaxWidth” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Jetpack Compose Academy, atualize para CoddyKit PRO. O curso de Jetpack Compose Academy inclui 4 aulas no total.

O que vou aprender em “Preenchimento, Tamanho e fillMaxWidth”?

Controle o espaço dentro e ao redor de uma Composable. Você pratica Jetpack Compose Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Jetpack Compose Academy?

Nenhuma experiência prévia é necessária. Jetpack Compose Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Preenchimento, Tamanho e fillMaxWidth”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Jetpack Compose Academy?

Sim. Cada aula de Jetpack Compose Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Preenchimento, Tamanho e fillMaxWidth
  2. Plano de Fundo, Borda e Recorte
  3. Por que a Ordem dos Modificadores Importa
  4. weight e Dimensionamento Flexível
← Voltar para Jetpack Compose Academy