airbnb / airbnb/epoxy

Wrap Item Width Carousel

Open
#752 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
8.6k
Forks
734
PR merge metrics
No merged PRs in 30d

Description

Is there way to have carousel items scrolling horizontally and have each item just wrap its width?

I am able to set number of items with numViewsToShowOnScreen, but the items in my carousel have dynamic widths, so I'd rather them just take up as much space as needed and the number of items on screen will be different based on the current visible items width.

Thanks a lot for the help! The library is great and I am really enjoying working with it.

Currently I tried subclassing carousel and having it set to wrap width in ModelSize and then setting SnapHelper to null

```
@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_WRAP_HEIGHT)
internal class SimpleWidthCarousel(context: Context) : Carousel(context) {

init {
setDefaultGlobalSnapHelperFactory(null)
setDefaultItemSpacingDp(0)
setPaddingDp(0)
}

override fun createLayoutManager(): LayoutManager {
return LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start with Carousel, especially createLayoutManager, ModelSize, SnapHelper, and numViewsToShowOnScreen, to understand how item sizing and snapping are currently connected. Verify the desired behavior by checking that horizontally scrolling items use their dynamic widths, show a variable number of items, and retain usable scrolling without the current workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.