Hello, I’m trying to get that children of `Horizon...
# compose
m
Hello, I’m trying to get that children of
HorizontalPager
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?
Copy code
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 = {  }
                    )
                }
            }
        }
c
I think you'll run into similar issues using LazyRow/LazyColumn. I think you'd need to implement your own measurement system to be able to do that 😞.
m
Yeah, that is what I also ended up figuring out after investigation, but decided to ask here in hope someone has some idea or solution. sad panda
141 Views