Recyclerview With Only One Item Displayed On Screen
I have RecyclerView with items ImageView. I want to make RecyclerView to display only one item at time, dragging to edge like ViewPager, when changing. Anyone knows how to achieve
Solution 1:
You can use the PagerSnapHelper class:
RecyclerViewrecyclerFoodItemsHorizontal= (RecyclerView) findViewById(R.id.recycler_food_items_horizontal);
SnapHelpermSnapHelper=newPagerSnapHelper();
mSnapHelper.attachToRecyclerView(recyclerFoodItemsHorizontal);
It will work similarly to ViewPager.
Solution 2:
As from I see you need a vertical ViewPager. I'm using castorflex/VerticalViewPager library for achieving that for one of my projects. It works just like a ViewPager, no code changes as I can see It's just a copy paste from the v19 ViewPager available in the support lib, where he changed all the left/right into top/bottom and X into Y.
Post a Comment for "Recyclerview With Only One Item Displayed On Screen"