Nat Strangerweather
04/26/2021, 5:59 PMModifier.fillMaxWidth
. The small Box has a width of Modifier.fillMaxWidth(1 / 7f)
. Elsewhere in my code outside my Composable I am defining an animation. There, I need the offset of my small Box to be the same as its width. Is there any way to use Modifier.fillMaxWidth
as a variable? If not, how can I get the right width for my offset?Zach Klippenstein (he/him) [MOD]
04/26/2021, 6:02 PMModifier.onSizeChanged
to get the size of a composable once it’s measured, although the size won’t be available until after the first composition (might be fine depending on your animation).
Since your width is also fixed relative to your parent, you could also use BoxWithConstraints
to get the max available width inside your big box and calculate the width for your child yourself (slightly less flexible, but available immediately).Nat Strangerweather
04/26/2021, 6:03 PMZach Klippenstein (he/him) [MOD]
04/26/2021, 6:04 PMAnimatedVisibility
code – some of the available transition animations offset a component by its own width, so similar idea.Nat Strangerweather
04/26/2021, 6:05 PMZach Klippenstein (he/him) [MOD]
04/26/2021, 6:06 PM