I have created a Box with a fixed size and it has a child that doesn't respect the parent's constraints. The child uses a requiredSize modifier to do this.
Box(Modifier
.size(50.dp)
.border(2.dp, Color.Red)
) {
Box(Modifier
.requiredSize(100.dp)
.background(Color.Yellow)) {}
}
By default, the Yellow child is aligned at the center position within the parent container.
I want to align it differently (say Alignment.BottomCenter) as shown below:
The documentation website says that I can apply wrapContentSize modifier to the child to do this. Here is the snippet from the documentation which I am referring to.
When I do as mentioned in the documentation, it does nothing.
Box(Modifier.size(50.dp).border(2.dp, Color.Red)) {
Box(Modifier
.requiredSize(100.dp)
.background(Color.Yellow)
.wrapContentSize(Alignment.BottomCenter)
) {}
}
Am I doing something wrong? How do I achieve the desired result?


