Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!