How to put RecyclerView inside NestedScrollView?

后端 未结 4 1529
南方客
南方客 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条回答
  •  抹茶落季
    2020-11-30 18:51

    The following is my new updated answer:

    
    
            
    
                
    
                    
    
                        
    
                        
    
                    
    
                
    
                
    
                    
    
                        
    
                        
    
                    
    
                
    
                
    
            
    
        
    

    In Activity:

            RecyclerViewAdapter recyclerViewAdapter = new RecyclerViewAdapter(true); // true: with header
            RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);            
            final MyLinearLayoutManager layoutManager = new MyLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false, getScreenHeight(this));
            // final CustomLinearLayoutManager layoutManager = new CustomLinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
            recyclerView.setLayoutManager(layoutManager);
            recyclerView.setAdapter(recyclerViewAdapter);  
            // recyclerView.setNestedScrollingEnabled(false); // Disables scrolling for RecyclerView, however, CustomLinearLayoutManager used instead of MyLinearLayoutManager
    

    I have also updated to My GitHub's sample project

    Screenshot:


提交回复
热议问题