Stylianos Gakis
11/12/2021, 9:36 AMLayout()
. Have some problems with constraints, more in thread 🧵Stylianos Gakis
11/12/2021, 9:37 AMLayout(
modifier = Modifier.size(40.dp),
content = {
Image(
painterResource(R.drawable.ic_something_with_24dp_size),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
Box(modifier = Modifier.size(12.dp)) {}
},
) { measurables, constraints ->
val image = measurables[0].measure(constraints)
val circle = measurables[1].measure(constraints)
// etc.
}
What should I do to mage image and circle measure with 24 and 12 dp respectively?
Now it gives them both 40.dp size just because the constraints allow it, but I have explicitly given them 24 and 12dp instead.Stylianos Gakis
11/12/2021, 9:39 AMval image = measurables[0].measure(constraints.copy(minWidth = 0, minHeight = 0))
val circle = measurables[1].measure(constraints.copy(minWidth = 0, minHeight = 0))
Fixes the problem, as before the constraints passed down were min AND max 110 (aka 40.dp).
Very interesting that it was like that, it’s probably because the .size()
modifier sets both min and max size for the item.