I’m doing something wrong here.. I’m trying to mak...
# compose
n
I’m doing something wrong here.. I’m trying to make sure that all the columns in my row has the same width and ultimately also fill the available space of the screen. Any input is appreciated 🙏 Code in thread 🧵
Copy code
@Composable
private fun RowScope.ScrollableContent(state: TableUiState, modifier: Modifier) {
    val scrollState: ScrollState = rememberScrollState()

    var width by remember { mutableStateOf(0.dp) }
    Row(
        modifier = modifier
            .background(colors.commonBackground)
            .horizontalScroll(scrollState)
            .weight(1f)
    ) {
        state.items.forEachIndexed { index, tableColumn ->
            val columnModifier = when (width) {
                0.dp -> Modifier
                else -> Modifier.width(width)
            }
            Column(modifier = columnModifier.layout { measurable, constraints ->
                val placeable = measurable.measure(constraints)
                if (placeable.width.dp > width) {
                    width = placeable.width.dp
                }

                // Return the placeable after setting the width
                layout(placeable.width, placeable.height) {
                    placeable.place(0, 0)
                }
            }) {
                tableColumn.items.forEach { tableItem ->
                    TableItemRow(tableItem = tableItem)
                }
            }
        }
    }
}
p
You can't use
weight(1f)
for every child in your row?
☝️ 1