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

如何点击显示详情? 将长按显示的view改为点击 #19

Open
chaopengTan opened this issue Mar 26, 2019 · 2 comments
Open

如何点击显示详情? 将长按显示的view改为点击 #19

chaopengTan opened this issue Mar 26, 2019 · 2 comments

Comments

@chaopengTan
Copy link

如题哦
将长按显示的view改为点击

@chaopengTan
Copy link
Author

在原来MotionEvent.ACTION_DOWN 添加 一个新的变量赋值
mTime = System.currentTimeMillis();

将原来MotionEvent.ACTION_UP 中改为
if(System.currentTimeMillis() -mTime <300 &&x == event.getX()){
isLongPress = true;
onLongPress(event);
invalidate();
}else{
if (x == event.getX()) {
if (isLongPress) {
isLongPress = false;
}
}
touch = false;
invalidate();
}

@VliceZ
Copy link

VliceZ commented Dec 13, 2019

还是有点问题
第一行应该改成:
if(System.currentTimeMillis() -mTime < 300*1000 && Math.abs(event.getX() - x) < 50){

时间应该从毫秒算起,所以需要乘以1000,手指点击的时候从down到up多多少少会带一点偏移直,接x == event.getX() 限制的太死了,会导致误判,所以我判断移动区间小于50个像素。

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

2 participants