With creation of NestedScrollView you can put scrolling view inside another scrolling view as long as those implement NestedScrollingChild and NestedScrollingParent correctly.
(This is not bad design pattern "Ian Lake (from Google) actually recommends putting a RecyclerView
inside a nestedscrollview here: plus.google.com/u/0/+AndroidDevelopers/posts/9kZ3SsXdT2T")
I want to put RecyclerView inside NestedScrollView and fortunately RecyclerView implements NestedScrollingChild so you can put it inside NestedScrollView.
public class RecyclerView extends ViewGroup implements ScrollingView, NestedScrollingChild
I have read these posts:
How to use RecyclerView inside NestedScrollView?
NestedScrolling with NestedScrollView, RecyclerView (Horizontal), inside a CoordinatorLayout
But the problem with most voted solution is, it calls all of the items of RecyclerView
so for example if it is an endless RecyclerView and when the user reaches the end of the list you want to make a network request then with that solution the RecyclerView
calls server repeatedly because it automatically reaches the last item of RecyclerView
.
Anyway, how to set parameter so I can put RecyclerView
inside NestedScrollView
.(actually I want to put a viewgroup like framelayout or relativelayout as a single childe of nestedscrollview and then I want to put recyclerview inside framelayout or relativelayout)
When I put RecyclerView
inside NestedScrollView
there is nothing to display.
In order to create a sample project you can use cheesesquare and change the CheeseDetailActivity
to have a RecyclerView.
Although the answer of BNK is not correct but BNK has tried a lot. So I award him the bounty. Still looking for nice solution....
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…