I want to removed side padding of particular child item in LazyColum. I solved this problem in xml with the help of this post. I have same scenario in the jetpack compose. I am using BOM versions of compose_bom = "2022.11.00" with Material 3.
Card(shape = RoundedCornerShape(6.dp),) {
Column(modifier.background(Color.White)) {
LazyColumn(
contentPadding = PaddingValues(all =16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
item {
Text(
text = "Device Header",
modifier = Modifier.padding(top = 10.dp),
style = headerTextStyle
)
}
item {
Divider() // remove padding from side in here
}
}
}
}
Actual Output
Expected Output


In Compose you can't use a negative padding in the children to reduce the padding applied by the parent container. You can use
offsetmodifer with a negative value but it will shift theDivideron the left side.You can use a
layoutmodifier to apply an horizontal offset increasing the width.Something like:
Here you can find the output with a
Divider()without modifier, and theDividerwith thelayoutmodifier.