Nested RecyclerView in ViewHolder breaks Collapsing Toolbar Layout

后端 未结 3 1087
清歌不尽
清歌不尽 2021-01-04 11:50

I have a vertical RecyclerView hosted in a CoordinatorLayout featuring a collapsing toolbar layout. The ViewHolder for this RecyclerView contains yet another RecyclerView wi

3条回答
  •  迷失自我
    2021-01-04 12:00

    So while the above is still true, I found a workaround.

    The workaround involves wrapping the ViewHolder RecyclerView in a RelativeLayout, and overlaying a transparent clickable view over it. In my case, I used a TextView.

    Now while fixes the scrolling, there's still the issue of passing clicks to the right ViewHolder in the ViewHolderRecyclerView. To work around this second setback, I extended the GestureDetector.SimpleOnGestureListener class to contain a recyclerView. Then, I set a OnTouchListener on the wrapperTextView which then forwards the MotionEvent to the GestureDetector.SimpleOnGestureListener subclass.

    The subclass finally interprets the motion event and passes it to the inner RecyclerView, which in turn from the coordinates of the click, figures out the child view clicked and calls performClick() on the child.

提交回复
热议问题