Can we pass the `align` parameter in `requiredHeig...
# compose
a
Can we pass the
align
parameter in
requiredHeightIn
or is there other way to achieve this?
z
Copy code
.wrapContentHeight(align = …)
.requiredHeightIn(…)
but then you probably don't even need `required`:
Copy code
.wrapContentHeight(unbounded = true, align = …)
.heightIn(…)
a
Yes that's how I changed my code, first I used
.requiredHeightIn(…)
then found the issue that my content was being central aligned(as mentioned in the doc) then used the
.wrapContentHeight(unbounded = true, align = …)
as I wanted to have my content not squeezed in the available space rather go outside the bounds of the parent Composable then thought there is no need of
requiredHeightIn
as
wrapContentHeight
with unbounded already discards the incoming max constraints
But then what will be the use of below code
Copy code
.requiredHeightIn(min = 40.dp)
when same can be achieved by
Copy code
.wrapContentHeight(unbounded = true)
.heightIn(min = 40.dp)
z
Good question, I would recommend the latter in almost all cases. I've used
requiredHeightIn
mostly in tests, where I want to force a container size but don't care how that container's parent places it.
👍 1
thank you color 1
The only other thing I can think of is that
required*
should still report the actual height to the parent via
Placeable.measuredHeight
, which you could potentially consume with a custom layout (afaik none of the built-in layouts read that property). But that smells pretty weird too, at that point I would probably expect the custom layout to just pass different constraints to the child.
👍 1