Scroll not working for multiple RecyclerView in BottomSheet

前端 未结 6 730
天命终不由人
天命终不由人 2020-12-14 09:04

I implemented BottomSheet using the DialogFragment approach. I have a TabLayout and ViewPager in the BottomSheet

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-14 09:54

    I had the same issue, to fix this without the need to override BottomSheetBehavior or the need of an additional library you can to the following: Implement a callback inside your bottom sheet implementation that registers changes of the page.

    fun onPageChanged(currentPage: Int) {
       recycler1.isNestedScrollingEnabled = currentPage == 0
       recycler2.isNestedScrollingEnabled = currentPage == 1
       dialog?.findViewById(R.id.design_bottom_sheet)?.requestLayout()
    }
    

    In the BottomSheetBehavior implementation in onLayoutChild a lookup for the first child that supports nested scrolling is performed, with this change the lookup is repeated. Not optimal solution but works fine in my case

提交回复
热议问题