I'm searching for a way to add a space between my items using a RecyclerView
and the PagerSnapHelper
.
To demonstrate what I mean here is a gif:
As you can see above between the two images there is a little black space. But these space is only available on scroll. If the scrollState is in SCROLL_STATE_IDLE
the image get centered snapped and are "full width".
That is what I want to achieve.
My idea was to add a new "placeholder" viewType
to my RecyclerView.Adapter
and customize the PagerSnapHelper
to "jump over" the placeholder viewType
(to jump over each second View
would be also possible).
But somehow this isn't working. I can't change the PagerSnaperHelper
(or the SnapHelper
with a lot of duplicated code from the PagerSnapHelper
) to work like I want. Even further while implementing it felt somehow wrong. It felt like "this is not the way it should be".
So - any recommendations or ideas how I can solve this? I'm totally open for all suggestions.
Disclamer:
I know I could use the old ViewPager
for this. But for special reasons I ask for an implementation for a RecyclerView
. So please don't suggest to use the ViewPager
here, thanks .