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.
Related
I have an activity that hosts 2 fragments, I am currently using a coordinator layout in both fragments with appbarlayout and toolbar layout, I have set it up this way to scroll the toolbar off screen with my recyclerview. This has been causing my layout issues as I've posted here So I am looking to change my approach. If I can the activity will host the tool bar/app bar layout in a coordinator layout.
The problem with this approach is that the 2 fragments have recyclerviews with views at the bottom (buttons). So I'm wondering if it's possible to transfer the scroll from the fragment recyclerview by setting the appbehaviour while maintaining the position of the buttons on the bottom?
Any help on this would be appreciated as I've spent days trying to figure out the alternative approach linked above.
Thanks
Yes it's possible, I'm doing this in an activity with a ViewPager, you just need to add
app:layout_behavior="#string/appbar_scrolling_view_behavior"
in the layout that holds the fragments (in my case the viewpager)
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.
This is a followup of this question where you can find all source code: Android does not show tabs
Originally I had no fragment, no tabs, just single activity that used NestedScrollView to hold its content and it worked like a charm - appbar was shortened when I scrolled and I was able to scroll the content.
Now I try to introduce tabs and I moved the content into new Fragment. I used ViewPager with layout_behavior attribute in the activity and LinearLayout in a fragment layout. I think that this is similar to CoordinatorExamples. But the content does not scroll at all and appbar is static, it does not changes when I try to scroll.
Where is the problem? The ViewPager must be OK as it works in the sample.
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
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.