Sliding conflict

When ScrollView is nested in RecyclerView, there will be a sliding conflict when sliding in the vertical direction

Internal intercept

By overriding the onTouchEvent method of RecyclerView to not consume the event, the event is reassigned to the ScrollView.

External intercept

The event is intercepted by overriding the ScrollView onInterceptTouchEvent.


According to not complete

After resolving the sliding conflict, the RecyclerView part is found to be incomplete. Log records show that both of the following solutions will cause all the data in RecyclerView to be loaded at once, which will cause performance problems (items cannot be reused) and is not suitable for loading large amounts of data. Personal feeling network data is generally the initial display of a few after the slide load again and again, the problem should not be big.

Using NestedScrollView

Nest a RelativeLayout layer outside the RecyclerView


The ScrollView slides to the bottom to refresh the data

notifyDataSetChanged

Internal through reqestLayout refresh, will refresh the whole RecyclerView

notifyItemRangeChanged

Only the elements in the specified range are refreshed


reference

  • Stackoverflow.com/questions/2…