Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

点击事件和卡片滑动有冲突 #21

Open
ThugKd opened this issue Aug 8, 2018 · 4 comments
Open

点击事件和卡片滑动有冲突 #21

ThugKd opened this issue Aug 8, 2018 · 4 comments

Comments

@ThugKd
Copy link

ThugKd commented Aug 8, 2018

我在三星s8上 点击事件和卡片滑动有冲突

@ThugKd
Copy link
Author

ThugKd commented Aug 9, 2018

我试了一下 三星手机都有问题 点击的时候卡片会微微晃动一下

@cvmars
Copy link

cvmars commented Mar 4, 2019

重写 CardLayoutManager onTouchListener


private float touchDownX;
private float touchDownY;
private final View.OnTouchListener mOnTouchListener = new View.OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        RecyclerView.ViewHolder childViewHolder = mRecyclerView.getChildViewHolder(v);
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                touchDownX = event.getX();
                touchDownY = event.getY();
                return false;
            case MotionEvent.ACTION_MOVE:
                boolean needSwipe = (Math.abs(touchDownX - event.getX()) >= ViewConfiguration.get(
                        mRecyclerView.getContext()).getScaledTouchSlop())
                        || (Math.abs(touchDownY - event.getY()) >= ViewConfiguration.get(
                        mRecyclerView.getContext()).getScaledTouchSlop());
                if (needSwipe) {
                    mItemTouchHelper.startSwipe(childViewHolder);
                    return false;
                }
                return true;
        }
        return v.onTouchEvent(event);
    }
};

@ender115
Copy link

重写CardLayoutManager onTouchListener好像也不行呀

@cctxwan
Copy link

cctxwan commented Oct 13, 2021

我的需求是这样的,在RecyclerView的item里面放了一个ImageView,ImageView的点击事件和滑动事件有冲突,我是这样处理的

//1单击 2左滑 3右滑
private int isMoveType = 1;

20211013152342

20211013152500
20211013152556
20211013152628

如果有问题,+vx:18588400509

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants