Quick question about <Horizontal Carousel> and upd...
# compose
b
Quick question about Horizontal Carousel and updating the number of items in the carousel. Given that the
CarouselState
is recommended to be setup like so:
Copy code
HorizontalMultiBrowseCarousel(
   modifier = carouselModifier,
   state = rememberCarouselState { images.size },
   ...
) { index ->
I am unsure of how, or if it is at all possible, to update size of the Carousel when the size of the
images.size
changes. I have tried various things, but there seem to be pros/cons to the approaches I have tried, like the Carousel jumping around. Is there a best/recommended approach to this?
r
you can search for the highest available item in carousel if you want it to be static and keep minimum height of an item in composable where its always the biggest one size
or just keep a static item height and prepare a background with proper image content fit, idk what you want to achieve
b
Thank you for the response. Luckily, I don't have an issue with the height of the Carousel, but the count of items in the Carousel. For example, starting off with 1, then having that count change to 10.
r
if you have problems with images jumping around when there are too little items so the positioning happens weirdly id try to go with "dummy" empty views added into it
just keep other carousel items dimension and control swiping by some logic