I want to implement a viewpager with fragments inside, one of the fragments has the NestedScrollView inside, but when I put the NestedScrollView inside the layout of a fragment and run the project . The app shows as the picture below:
The scroll gesture of NestedScrollView working well with the AppBarLayout, but NestedScrollView prevents the swipe gesture of viewpager. When the NestedScrollView scrolls down a little,the AppBarLayout collapsed ,the swipe gesture cannot fired, so I cannot move to the next page of viewpager. This only happens with the NestedScrollView, the RecyclerView works well .
How can I make the NestedScrollView working well with the fragment?
This is the demo I told above: demo ,please change the layout of the fragment inside viewpager with the layout below:
lipsum is the very very long string
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 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);
Ok so I have a global CoordinatorLayout with the following layout
content_main is a FrameLayout that fragments are transacted into. For this particular fragment I have a requirement of placing a TabLayout at a certain % of screenheight, so I went the route of using a ViewPager (with each fragment containing a NestedScrollView to coordinate with the CoordinatorLayout for proper scrolling behavior -- which all works as expected). However my transacted fragment layout (NestedScrollView) is not scrolling at all, however the layout_behavior is working as the AppBar/ToolBar are reacting to a scroll.
Any help on this would be greatly appreciated.
EDIT: I have created a sample project to show current broken behavior. https://github.com/bmc08gt/NestedScrollView-with-ViewPager The intended behavior is for the tablayout to collapse to the toolbar.
So I have a Fragment which uses a CoordinatorLayout with a NestedScrollView inside. Inside that NestedScrollView is a ViewPager. Each item of that ViewPager is a CoordinatorLayout with a NestedScrollView inside.
The behavior I want is that when each item inside the ViewPager is scrolled up and down, my custom BottomBar will disappear and reappear.
When I scroll up and down, however, the BottomBar disappears and reappears, but the content in the innermost ScrollView does not move. This is the problem
Code posted below, any advice would be helpful.
Things I've tried:
Calling ViewCompat.setNestedScrollingEnabled() on nearly every view in the hierarchy that could scroll.
Calling requestDisallowInterceptTouchEvent(true) on the outermost NestedScrollView.
Main Activity:
Fragment w/ outer NestedScrollView:
Each item in ViewPager:
app:layout_behavior="#string/appbar_scrolling_view_behavior"
set this line in ViewPager it will help you
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.