RecyclerView inside NestedScrollView onBindViewHolder calling for all getItemCount size

后端 未结 4 1803
谎友^
谎友^ 2021-01-04 18:53

When I put RecyclerView inside NestedScrollView then onBindViewHolder is calling for all row like say I have list which has size of 30

4条回答
  •  清歌不尽
    2021-01-04 19:15

    I'm going to assume that since your are using appbar_scrolling_view_behavior you are trying to do something with AppBarLayout.

    If so, you can use RecyclerView as a direct child of CoordinatorLayout and have support for AppBarLayout scrolling without nesting RecyclerView inside of NestedScrollView.

    Try this: RecyclerView inside CoordinatorLayout (with AppBarLayout and CollapsingToolbarLayout):

    
    
        
    
            
    
                
    
            
        
    
        
    
    

    And in your Activity or CustomView:

    RecyclerView list;
    LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    list.setLayoutManager(layoutManager);
    list.addItemDecoration(new VerticalSpaceItemDecoration(5));
    list.setAdapter(adapter);
    

提交回复
热议问题