I'm build a layout in compose that contains a LazyHorizontalGrid with 2 rows of cards, let's say:
Код: Выделить всё
LazyHorizontalGrid( rows = GridCells.Fixed(2), contentPadding = PaddingValues(horizontal = 16.dp), modifier = Modifier .fillMaxWidth() .aspectRatio(2F) //Workaround that I found to try to limit LazyHorizontalGrid Height ) { item(5){ Card { Column { Text(text = stringResource(id = R.string.item_title)) Spacer(modifier = Modifier.height(12.dp)) Image(painter = painterResource(id = R.drawable.item_image), contentDescription = null ) } } } } I placed a aspect ratio to try to limit the height of my items (by limiting the height of LazyHorizontalGrid itself). There will be other elements below the LazyHorizontalGrid.
How Can I achieve "wrap_content" behaviour for item's height inside LazyHorizontalGrid?
Things I tried:
- Use - I can't. I need two rows regardless of screen size
Код: Выделить всё
GridCells.FixedSize() - User for
Код: Выделить всё
verticalArrangement- No difference at allКод: Выделить всё
LazyHorizontalGrid - Add at
Код: Выделить всё
Modifier.wrapContentHeight()composable - No difference at allКод: Выделить всё
Card's
Источник: https://stackoverflow.com/questions/781 ... lgrid-in-c
Мобильная версия