Justin
03/07/2022, 12:24 PMBoxWithConstraints
. 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:
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.