I'm using a horizontal RecyclerView with PagerSnapHelper to make it look like a ViewPager. It's displaying child views.
How can I make it show a small peek of the next entry? The user needs to see close to 20% of the next entry to understand intuitively that they need to swipe horizontally. The earlier entry needs to align back.
There could be other indications of dots at the bottom but this is the expected behaviour. The child view occupies the entire recycler view, so adjusting the width of the child so as to make other siblings come onto the screen isn't an option.
Right now I'm using a RecyclerView that is set up with a PagerSnapHelper.
I'm able to scroll to 20% of the next entry by using this:
val nextPosition = (currentPosition + 1) % numOfEntries
val xscrollDistance = carouselRecyclerView.width * 0.80
linearLayoutManager.scrollToPositionWithOffset(nextPosition, xscrollDistance.toInt())
With this, I see the next entry come onto the screen like a peek but here's what I'm unhappy with:
- This scroll isn't smooth, I'm looking for a smooth scroll to the 20% peek of the next entry
- Snap doesn't work. I was hoping when I do step 1., the snap behaviour will kick in and align the earlier entry onto the screen. It doesn't happen that way.
- The peeking behaviour also needs to be cyclic. Last entry's peek should be the 0th entry.
I'm also looking for a less complex solution if any.
I checked an older solution - How to peek RecyclerView + PagerSnapHelper but I'm hoping to find a cleaner solution instead.