When I set my pleaceable constraint as below.
LazyColumn(
contentPadding = PaddingValues(all =64.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
val adjust = 32.dp
item {
Divider(modifier = Modifier.height(20.dp))
}
item {
Divider(modifier = Modifier.height(20.dp)
.layout { measurable, constraints ->
val placeable =
// -32.dp offset constraint
measurable.measure(constraints.offset(-adjust.roundToPx()))
layout(placeable.width, placeable.height
) { placeable.place(0, 0) }
}
)
}
item {
Divider(modifier = Modifier.height(20.dp)
.layout { measurable, constraints ->
val placeable =
// +32.dp offset constraint
measurable.measure(constraints.offset(adjust.roundToPx()))
layout(placeable.width, placeable.height
) { placeable.place(0, 0) }
}
)
}
}
The 3 rows of items result (as shown in the image) below whereby
- First row is the reference
- Second row shorted on the right side by 32.dp
- Third row, increase both sides by 16.dp
Why does the second and third-row behavior differs i.e. 2nd row shrink just on the right, while 3rd row expands on both side equally?

It's not exactly about adding or subtracting, these operations work as expected when they return values in min-max bounds of
Constraints.It's because setting layout width/height a Composable out of
Constraintsmin-max bounds results it's being placed as the half of difference betweenContraintsand the value used inlayout()function.When layout width is bigger than constraints.maxWidth
(constraints.maxWidth-layout(width))/2which means placed with offset to the leftwhen layout width is smaller than constraints.minWidth
(
constraint.minWidth-layout(width))/2which means placed with offset to the right.You can refer this tutorial for more samples, information and examples about how layout, and Constraints work.
https://github.com/SmartToolFactory/Jetpack-Compose-Tutorials/blob/master/Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter3_layout/Tutorial3_2_4ConstraintsBounds.kt
https://github.com/SmartToolFactory/Jetpack-Compose-Tutorials/blob/master/Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter3_layout/Tutorial3_2_5SiblingConstraints.kt
https://github.com/SmartToolFactory/Jetpack-Compose-Tutorials/blob/master/Tutorial1-1Basics/src/main/java/com/smarttoolfactory/tutorial1_1basics/chapter3_layout/Tutorial3_2_6ConstrainAndOffset1.kt
Also when you change as in snippet below it will be more clear to see how it works
Placable width is same(300px) for both instances