Nested RecyclerView. How to prevent parent RecyclerView from getting scrolled while child RecyclerView is scrolling?

前端 未结 14 1350
余生分开走
余生分开走 2020-12-07 21:24

I am trying to implement a horizontal recyclerview and each item of the recyclerview will be a vertical recyclerview with a grid layou

14条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 21:44

    I used card view for cells and deactivated parent recycler view scrolling in child adapter with child cell itemView setOnClickListener.

    holder.itemView.setOnTouchListener { view, _ ->
        view.parent.parent.requestDisallowInterceptTouchEvent(true)
        false
    }
    

    we are calling view.parent.parent because of the fact that itemView is a cell layout and it's parent is our child recyclerView and also, we need to reach child recyclerView's parent to prevent parent recyclerView scrolling.

提交回复
热议问题