How do I position/size objects inside an Android jetpack compose Box by percent?

Viewed 836

I'm just starting with Android jetpack compose and would like to place a button in a Box and have the button be 20% as wide as the width of the Box and have it be 50% of the width of the Box. In the old ContraintLayout, I could do this with layout_constraintGuide_percent.

1 Answers

You can set the width and height with respect to parent like this,

Button(modifier = Modifier.
       fillMaxWidth(0.5f)) //50% width as the parent 
Related