I’m trying to create a UI in Jetpack Compose where each child Composable has the same height as the tallest child Composable.
https://i.sstatic.net/AOIyAF8J.png
Initially, I implemented this using Row and IntrinsicSize, but I noticed that the efficiency decreases as the number of items in the Row increases.
Row(
modifier = Modifier
.fillMaxWidth()
.height(IntrinsicSize.Max)
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement
.spacedBy(
space = Theme.dimen.spacingS,
alignment = Alignment.CenterHorizontally
)
) {
teams.forEachIndexed { index, item ->
key(item.id) {
VerticalTeamItem(
modifier = Modifier
.fillMaxHeight()
.padding(
start = if (index == 0) Theme.dimen.paddingL else 0.dp,
end = if (index == teams.lastIndex) Theme.dimen.paddingL else 0.dp
)
)
}
}
}
However, when using Row, the process of calculating the height of each item becomes increasingly inefficient as the number of items grows. Therefore, I am curious if there is a way to implement the above UI using LazyRow instead of Row to improve efficiency.
user25428584 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.