Two RecyclerViews under each other in one layout

前端 未结 7 891
不知归路
不知归路 2020-12-13 18:21

How can I get two RecyclerViews under each other in one layout? I don\'t want to have a single RecyclerView for all items. My code:



        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 18:50

    You should create an XML layout file like this

    
    
            
    
                
    
                
            
    
    

    And in the code, you should call setNestedScrollingEnabled(false)

    RecyclerView ingredientsList = findViewById(R.id.ingredients_list);
    RecyclerView stepsList = findViewById(R.id.steps_list);
    
    ingredientsList.setNestedScrollingEnabled(false);
    stepsList.setNestedScrollingEnabled(false);
    

提交回复
热议问题