Код:
data class Cell(
val name: String,
val weight: Float
)
@Composable
fun RowScope.TableCell(...) { /* same as in the linked code */ }
@Composable
fun MyTable(data: List) {
val columns = listOf(
Cell("a", .25f),
Cell("b", .25f),
Cell("c", .25f),
Cell("d", .25f)
)
LazyColumn(
Modifier
.fillMaxSize()
.padding(16.dp)
) {
item {
Row {
columns.forEach {
TableCell(
text = it.name,
weight = it.weight
)
}
}
}
items(data) {
Row(Modifier.fillMaxWidth()) {
TableCell(
text = it.somenumber.toString(),
weight = columns[0].weight
)
TableCell(
text = "Abc",
weight = columns[1].weight
)
TableCell(
text = it.somestring1,
weight = columns[2].weight
)
TableCell(
text = it.somestring2,
weight = columns[3].weight
)
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/708 ... -same-size