https://kotlinlang.org logo
#compose
Title
# compose
i

Ian Warwick

07/01/2022, 11:48 AM
Hey all is there any way for a
Box
to stop constraining its children? I just want them to overflow when I
offset(x,y)
them or size them
Copy code
Box(Modifier.size(256.dp)) {
    Box(Modifier.border(2.dp, Color.Red).size(512.dp)) {
    }
}
The inner box always gets constrained to the outer box which I don’t want, but I do want all the cool things about the box such as
Alignment
I just don’t want it to constrain children size, any ideas? 🙂
m

MR3Y

07/01/2022, 12:23 PM
You can achieve that by appending
wrapContentSize(unbounded=true)
modifier to the chain of the outer Box's modifiers:
Copy code
Box(Modifier.size(256.dp).wrapContentSize(unbounded=true)) {
    Box(Modifier.border(2.dp, Color.Red).size(512.dp)) {
    }
}
❤️ 1
i

Ian Warwick

07/01/2022, 1:54 PM
ah nice one!
4 Views