Hi all. Im trying to make this raw-payload view sc...
# compose
x
Hi all. Im trying to make this raw-payload view scrollable horizontally so that it doesn't wrap and ruin all the formatting. My layout looks like this
Copy code
LazyVerticalGrid(columns = GridCells.Adaptive(256.dp), ..) {
  ..
  item { TransactionDetailItem( label = { .. }, description = { .. }, ) }

  item(span = { GridItemSpan(this.maxLineSpan) }) {
    TransactionDetailItem(
      label = { .. },
      description = {
        Surface(..) {
          Text(
            text = raw,
            modifier = Modifier
              .horizontalScroll(rememberScrollState())
              .padding(8.dp),
          )
        }
      },
    )
  }
}
This works okay for smaller raw payloads, but throws with this exception when the raw text is larger
Copy code
java.lang.IllegalArgumentException: Can't represent a size of 4660198 in Constraints
Found this issue on the tracker that is relevant i think but was supposedly fixed in foundation
1.3.0-beta02
. But I was able to reproduce this in
1.4.3
. Am i missing something here? 🤔
a
This is not a bug. See the document of `Constraints`:
Constraints uses a Long to represent four values, minWidth, minHeight, maxWidth, and maxHeight. The range of the values varies to allow for at most 256K in one dimension.
Laying out such long text all at once is extremely inperformant and you should split the text anyway.
âž• 1
x
I see. Whats the best way to handle this? 🤔 I still want the users to be able to switch between wrap and no-wrap but no wrap takes more width than compose can calculate
a
Maybe you can use a lazy table-like layout.