tylerwilson
09/03/2021, 6:55 PMBox(fillMaxWidth) {
Row(horizontalScroll) {
items.forEach {
Column(width(<boxWidth here>) {
}
}
}
}
I want to dynamically change the inner column width to be the same as the ancestor box (it should be width of device), or some percentage (half or quarter). How can I reference the Box width in order to size the Column(s) properly? Thank you!Zach Klippenstein (he/him) [MOD]
09/03/2021, 7:09 PMmatchParentSize()
on the BoxScope
might work for this? But only if your row is already matching the box height. https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/BoxScope#(androidx.compose.ui.Modifier).matchParentSize()tylerwilson
09/03/2021, 7:13 PMZach Klippenstein (he/him) [MOD]
09/03/2021, 7:14 PMtylerwilson
09/03/2021, 7:14 PMtylerwilson
09/03/2021, 7:16 PMBox(modifier = Modifier.fillMaxWidth()) { boxScope ->
but it then creates errors in my treeZach Klippenstein (he/him) [MOD]
09/03/2021, 7:17 PMBoxScope
is the lambda receiver.Zach Klippenstein (he/him) [MOD]
09/03/2021, 7:18 PMmatchParentSize()
doesn't do the right thing?tylerwilson
09/03/2021, 7:19 PMtylerwilson
09/03/2021, 7:19 PMBox(modifier = Modifier.fillMaxWidth()) {
val boxSize = Modifier.matchParentSize()
Row(modifier = Modifier
.horizontalScroll(rememberScrollState())) {
book.staff.forEach { staff ->
Column(
//modifier = boxSize
modifier = boxSize //Modifier
//boxScope.matchParentSize()
//.fillMaxWidth(1.0f)
//.width(320.dp)
)
Zach Klippenstein (he/him) [MOD]
09/03/2021, 7:21 PMBoxWithConstraints
and then just pass the width
modifier with the maxWidth
tylerwilson
09/03/2021, 7:21 PMtylerwilson
09/03/2021, 7:26 PMZach Klippenstein (he/him) [MOD]
09/03/2021, 7:26 PMtylerwilson
09/03/2021, 7:27 PMZach Klippenstein (he/him) [MOD]
09/03/2021, 7:28 PMtylerwilson
09/03/2021, 7:29 PMtylerwilson
09/03/2021, 7:31 PMZach Klippenstein (he/him) [MOD]
09/03/2021, 7:32 PMtylerwilson
09/03/2021, 7:33 PMZach Klippenstein (he/him) [MOD]
09/03/2021, 7:36 PMWill Shelor
09/04/2021, 12:41 AMAlbert Chang
09/04/2021, 3:05 AMLazyRow
instead of a Row
so that you can use Modifier.fillParentMaxWidth()
on the `Column`s.
Box(fillMaxWidth) {
LazyRow {
items(items) {
Column(fillParentMaxWidth) {
}
}
}
}
Didn’t try but I think it should work.tylerwilson
09/04/2021, 6:30 PMAlbert Chang
09/05/2021, 10:00 AMtylerwilson
09/05/2021, 5:06 PM