dimsuz
05/03/2022, 1:34 PMButton(
modifier = Modifier.widthIn(min = 365.dp),
onClick = {}
) {
Layout({ Text("hello") }) { measureables, constraints ->
println("$constraints")
}
}
I thought that incoming constraints
would have minWidth set to 365.dp
, but they are actually minWidth=0, maxWidth=636.dp
which comes from Button
parent.
What is the correct way to layout button's content with respect to imposed min size on the button?Louis Pullen-Freilich [G]
05/03/2022, 1:38 PMmodifier
as a parameter to Layout
in the code you shareddimsuz
05/03/2022, 3:27 PMButton
and not into its content.
Or should I pass 2 modifiers in this case? Never saw this in compose samples though...Louis Pullen-Freilich [G]
05/03/2022, 3:29 PMButton
function, I didn’t realize that was a function call inside something else. What is the parent of button in this case? If the parent is making button bigger, then it seems reasonable - you are only setting the min width on button, so it can be forced to be bigger if the parent is measuring it with more spacedimsuz
05/03/2022, 3:40 PMButton(
modifier = Modifier.widthIn(200.dp),
content = {
Spacer(modifier = Modifier.weight(1f))
Text("Button")
Spacer(modifier = Modifier.weight(1f))
CircleProgressBar()
}
)
This results in Button which ignores 200.dp and always fills max size.
And I don't want to do requireMinWidth(200.dp)
, because if text is over 200.dp, I want button to expand accordingly.Louis Pullen-Freilich [G]
05/03/2022, 5:15 PMLayout
. And the Button
will size itself to make space for thatdimsuz
05/03/2022, 6:38 PMUiKitButton(modifier = Modifier.widthIn(min = 200.dp)) // implemented using material.Button
And then I'd like the content
which I pass to the Button
inside UiKitButton
to be stretched to that min
. I have no way to extract those "200.dp" from the modifier to pass it to the content.
Another option is to use
UiKitButton(minWidth = 200.dp)
But I don't like it much, because I would prefer to deliver layout constraints using modifiers.Zach Klippenstein (he/him) [MOD]
05/10/2022, 3:00 PMdimsuz
05/12/2022, 11:25 AM