Scolling with multiple RecyclerViews in Layout

前端 未结 2 623
后悔当初
后悔当初 2020-12-14 13:13

I have created a layout which has two RecyclerViews. One scrolls horizontally while other scrolls vertically. I can scroll correctly inside each RecyclerView but the page as

2条回答
  •  佛祖请我去吃肉
    2020-12-14 13:41

    I was able to solve the problem by putting everything inside ScrollView and then setting height of vertical RecyclerView manually/programmatically.

    
    
    
        
    
                
    
    
                
    
                
                
    
                
    
                
                
    
    
        
    
    

    Setting RecyclerView's height programmatically:

    LinearLayout.LayoutParams params = new     
         LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 
         ViewGroup.LayoutParams.WRAP_CONTENT);
    // calculate height of RecyclerView based on child count
    params.height=1150;
    // set height of RecyclerView
    recyclerView.setLayoutParams(params);
    

提交回复
热议问题