How to put RecyclerView inside NestedScrollView?

后端 未结 4 1528
南方客
南方客 2020-11-30 18:30

With creation of NestedScrollView you can put scrolling view inside another scrolling view as long as those implement NestedScrollingChild and NestedScrollingParent correctl

4条回答
  •  -上瘾入骨i
    2020-11-30 18:49

    I have wasted at least a week behind this and the only solution that works is to remove the nestedscrollview. I know that is not the answer to this particular question of adding recyclerview inside nestedscrollview, but to make the recyclerview to actually recycle the view, you HAVE TO REMOVE the nestedscrollview. If you happen to have multiple view inside instead of just the recyclerview, You have to add them as items of the recyclerview by setting different viewholders, and then adding

    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    to the recyclerview or the parent of recyclerview(the parent cannot have any other view other than Recyclerview for this to work).

    In my case, the requirement was as follows:

      
    
            
    
            
    
                
    
                    
    
                        
                    
    
                    
                
            
    
            
                
                      
                    
                    
            
        
    
    

    I needed to have two views before recyclerview and I wanted them to do nestedscroll along with recyclerview. The only thing that worked was by removing these to views and adding them as the first two items of recyclerview, and then adding

    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    

    to the swipetorefresh layout

    Hope this helps someone. I will add more info If required.

提交回复
热议问题