How can I put a bigger composable in a smaller par...
# compose
m
How can I put a bigger composable in a smaller parent (both with fixed sizes), so that it's clipped? (like would happen by default with Views) My child composable just resizes itself to fit into the parent, which I don't want. I tried using
requiredWidth()
but that centers it inside the parent (it overflows to both sides), where I want it left-aligned and clipped on the right.
1
a
Use
Modifier.layout {}
to write a layout modifier that permits a larger max size for the child than the incoming constraints, then place the child as desired
then use a
.clip()
before your custom modifier
z
I think you can also do
Modifier.wrapContentSize(align = Alignment.TopLeft, unbounded = true)
on the parent
🎉 1
m
Thank you,
clipToBounds()
+
wrapContentSize()
worked.