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

Vaibhav Jaiswal

03/02/2024, 12:42 PM
How can i set maxWidth in %age?
s

Sean Proctor

03/02/2024, 2:04 PM
I don't think you can. You can use
.weight
to get a percentage.
You can use
BoxWithConstraints
or
Layout
also, if you want more control over your content size.
👎🏾 1
z

Zach Klippenstein (he/him) [MOD]

03/02/2024, 5:19 PM
Copy code
Modifier.fillMaxWidth(fraction = TODO())
v

Vaibhav Jaiswal

03/03/2024, 6:32 AM
@Zach Klippenstein (he/him) [MOD] I meant MaxHeight using
widthIn()
but max value is a %age
@Sean Proctor Thanks, I'll give it a try
s

Stylianos Gakis

03/03/2024, 9:37 AM
Percentage of what? If it's height why not fillMaxHeight(%age)
v

Vaibhav Jaiswal

03/03/2024, 9:38 AM
Wont fillMaxHeight/fillMaxWidth occupy the %age i pass even if the content is smaller than that I want it to grow at max to that %age of height/width
s

Stylianos Gakis

03/03/2024, 9:42 AM
Try doing fillMaxSize which will make the layout take that much height, and after it do wrapContentHeight, so that it will shrink to take the amount it actually needs. I'd try something like that myself
2 Views