I am facing a problem with Recyclerview inside Viewpager fragments.
I have two fragments and both loaded in ViewpagerAdapter. In the second fragment, I have a simple Horizontal Recyclerview. Initially, 1st fragment is loaded in ViewPager and when I swipe right to left on screen it will redirect me to the second fragment.
In the second fragment Recyclerview already loaded. But when I tried to scroll Recyclerview horizontally for more items it is not scrolling it redirects me to the 1st fragment from swipe left to right.
How to allow the user to view more items?
Help me with this problem.
Thanks in advance.
Try to enable Nested Scrolling for recyclerview
after initialising your recyclerview, add this line of code
your_recyclerview.setNestedScrollingEnabled(true);
Related
I have a ViewPager. Inside this ViewPager I have Fragments that have all the same layout. The layout contains a header and a RecyclerView and I want only the header of this layout to be swipeable. So the user may only switch between the fragments inside the viewpager when he is swipping on the header. I have tried a CustomViewPager but it was not working the way I wanted it to.
Does someone have a solution?
My dirty but working solution is to set a custom TouchListener to my header view and every time it detects a fling to the right or left I call setCurrentItem(index, true) with the ViewPager. It is not the optimal solution, but is working for now.
I am having a layout in which I am using CoordinatorLayout and NestedScrollView. I am using viewpager with 3 tabs in the nested scrollview. I am using fragments for the tabs and in one of the tab I am having Gridview.
So now, gridview scrolling is working inside that fragment only, I want the scrolling in the whole page.
Can you please help me here.
Thank you so much in advance.
I have an activity layout in which I have a viewpager that contains a couple of fragments. One of the fragment holds a listview (image sample attached).
What I'm trying to do is to scroll the listview and stick the TabStrip to the top of the layout, so when you are scrolling the list, the viewpager's fragment titles are always visible but you can see the entire listview content.
Above the viewpager there are views that needs to scroll up when the listview is scrolling.
Is any way to achieve this?
I've tried with scrollview and placing the viewpager inside it, but it doesn't work because the viewpager doesn't display at all.
Please help!
i've found the solution by using this nice library from github!!!
noties/Scrollable
I am trying to scroll more than one item in a ViewPager per swipe. I have implemented a carousel like ViewPager by setting the PagerAdapter's getPageWidth() to return .33f. And I am trying to scroll 3 items per swipe. I have tried incrementing position in ViewPager.onPageScrolled(). But it isn't working.
ViewPager is not the answer. You need HorizontalScrollView with paging. that enables you when flinging to swipe multiple pages but doesnt stop in the middle of a page.
In case u still want ViewPager -
Read this
I have an activity. Inside that activity I have implemented VerticalViewPager in which 3 pages are fed i.e. Upper Page, Middle page and Lower Page. Inside the middle page fragment and Lower page fragment I have separately another ViewPagers(Horizontal).Inside these ViewPagers I have 3/3 pages each. So far I have been able to make them working just fine i.e. on vertical swipe gesture the VerticalViewPager gets triggered and on horizontal swipe gesture native android ViewPager gets triggered. Now I need to sync the horizontal swipe transition between the middle fragment pages and lower fragment pages.
Let me give an example: say I have A,B and C pages inside middle fragment of VerticalViewPager and D,E,F inside the lower vertical fragment. Assume I am in the middle fragment now. So when I swipe from A to B left to right, the lower fragment should also swipe from D to E automatically.
[P.S.: For the horizontal(native) ViewPager to work inside
VerticalViewPager, the horizontal ViewPager Adapter needs to run
in the AsyncTask or threads. So please consider this scenario as
well]
You can make the adapter scope available globally and set the current view or fragment according to the change in the middle fragment.
According to the example: