本文主要是介绍RecycleView嵌套RecycleView解决上下和左右滚动冲突的方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
思路 复写RecycleView的InterceptTouchEvent()方法,代码如下:
public class MyRecyclerView extends RecyclerView {private int touchSlop;private Context mContext;private int INVALID_POINTER = -1;private int scrollPointerId = INVALID_POINTER;private int initialTouchX;private int initialTouchY;public MyRecyclerView(Context context) {this(context, null);}public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {this(context, attrs, 0);}public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);ViewConfiguration vc = ViewConfiguration.get(context);touchSlop = vc.getScaledEdgeSlop();mContext = context;}@Overridepublic boolean onInterceptTouchEvent(MotionEvent e) {if (e == null) {retur
这篇关于RecycleView嵌套RecycleView解决上下和左右滚动冲突的方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!