Hi, i’m running into a challenge with getting the ...
# compose
j
Hi, i’m running into a challenge with getting the maxWidth of a scrollable
BoxWithConstraints
. I’ve displayed a list of items in a
Row
. I’m looking to display a column layout if the user has selected a system font size that makes the row’s size greater than the
maxWidth
of the viewport. I can get the width of the viewport by using
BoxWithConstraints
. For the scrollable row of items, the items list is dynamic so i have wrapped this inside another
BoxWithConstraints
like this:
Copy code
BoxWithConstraints(
        Modifier.horizontalScroll(rememberScrollState())
    ) {
      Row(modifier = modifier.fillMaxWidth()) {
        // ... list of items
      }
}
My idea is the get the maxWidth of the inner
BoxWithConstraints
and compare it with with the parent maxWidth to determine what to lay out. However the scrollable inner
BoxWithConstraints
is giving me a width that is very large (eg: pixel 3XL is 4.77218592E8dp). Can someone advise on this approach and whether my idea is possible or whether I need to try something different? Thanks.