Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
How can we define a column with padding and just one item doesn't inherit the padding of the column in Jetpack Compose?

I have a column with many items, and I want to set the padding for the column because all items have the same padding except one of them which doesn't have padding, how can I consider an exception for that specific item? Or is it possible to add an attribute that says don't get your parent padding? I know I can remove padding for column and add one by one, but I want to ask anybody knows that, is there any other way?

Column(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState()),
            .padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(16.dp)
    ) {
 Text(text = "Teaser1")

Text(text = "Teaser2")

Text(text = "Teaser3")

Text(text = "Teaser")

Text(text = "Teaser4")

Text(text = "Teaser5")

...

}

Thank you in advance for your help.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use Modifier.layout.

I override the width constraint by adding padding for measure, and applying the padding offset during place.

Text(
    text = "Teaser",
    modifier = Modifier
        .layout { measurable, constraints ->
            val noPaddingConstraints = constraints.copy(
                maxWidth = constraints.maxWidth + (padding * 2).roundToPx()
            ) 
            val placeable = measurable.measure(noPaddingConstraints)
            layout(placeable.width, placeable.height) {
                placeable.place(x = -padding.roundToPx(), y = 0)
            }
        }
)
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda