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

spierce7

06/16/2022, 5:34 PM
I feel a little dumb for asking this, but is there a way to allow a child Composable to be larger than a parent Composable?
👌 1
t

Tgo1014

06/16/2022, 5:47 PM
wrapContentSize(unbounded = true)
maybe?
a

Adam Powell

06/16/2022, 8:15 PM
Making a child larger than the parent is exactly what scrolling containers and modifiers do, so yes 🙂
A parent (
Layout
composable or
Modifier.layout
) can measure children however it likes so long as its own reported size matches its requested constraints
s

spierce7

06/16/2022, 8:18 PM
To be clear, I meant for a child to draw outside the bounds of it’s parents, and actually appear larger
it’s an odd use-case
a

Adam Powell

06/16/2022, 8:26 PM
The answer is still yes, layouts in compose don't clip by default, though a few material containers do
s

spierce7

06/16/2022, 8:33 PM
So if I have an image thats 500dpX500dp, inside of a Box that’s 100dp X 100dp, it won’t clip, and I could still center it?
a

Adam Powell

06/16/2022, 8:55 PM
Assuming none of the other containers between that and the root clip it, yes
7 Views