1.话不多说,直接上代码
public class MyRecycleView extends RecyclerView { public MyRecycleView(Context context) { super(context); } public MyRecycleView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public MyRecycleView(Context context, @Nullable AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean onInterceptTouchEvent(MotionEvent e) { //返回false,则把事件交给子控件的onInterceptTouchEvent()处理 return false; } @Override public boolean onTouchEvent(MotionEvent e) { //返回true,则后续事件可以继续传递给该View的onTouchEvent()处理 return true; } }
2.实现效果
本人也是试了好久,才实现这样的效果,之前的简直是卡成狗了。