Marko Novina
05/11/2023, 7:46 AMHorizontalPager
are all same size which is size of biggest child. I only have 3 items so I set beyondBoundsPageCount
so that all items are composed so that HorizontalPager
knows what should be his size. Issue is I can’t manage to get it to work. Is something like that even possible?
BoxWithConstraints {
HorizontalPager(
modifier = Modifier.height(constraints.maxHeight.pxToDp()), // tried to add this - didn't help
pageCount = items.size,
contentPadding = PaddingValues(horizontal = 20.dp),
pageSpacing = 12.dp,
// child width should be 82% of available width so that next item "peeks"
pageSize = PageSize.Fixed((constraints.maxWidth * 0.82).toInt().pxToDp()),
beyondBoundsPageCount = items.size,
) {
with(items[it]) {
ItemCard(
// setting height explicitly or fillMaxHeight doesn't work, and yes I have spacer with weight 1 inside
modifier = Modifier.height(constraints.maxHeight.pxToDp()),
icon = icon,
title = title,
description = description,
actionText = actionText,
actionIcon = actionIcon,
onCardClick = { }
)
}
}
}
czuckie
05/11/2023, 10:49 AMMarko Novina
05/11/2023, 11:15 AM