[英]MotionEvent ACTION_MOVE inaccurately generated on some devices
I am using a simple function that intercepts and processes MotionEvents on a custom FrameLayout and interprets clicks.我正在使用一个简单的 function 拦截和处理自定义 FrameLayout 上的 MotionEvents 并解释点击。 It works flawlessly on one device.
它可以在一台设备上完美运行。 However, when I click on another device, it generates ACTION_MOVE events as long as my finger still touches the screen.
但是,当我单击另一个设备时,只要我的手指仍然触摸屏幕,它就会生成 ACTION_MOVE 事件。 I do not move it.
我不动它。 I wonder, why do the events created on 2 devices differ so much?
我想知道,为什么在 2 台设备上创建的事件差异如此之大?
This is the code from my simple method这是我的简单方法中的代码
interceptTouchFrameLayout.setOnInterceptTouchEventListener(new InterceptTouchFrameLayout.OnInterceptTouchEventListener() {
@Override
public boolean onInterceptTouchEvent(InterceptTouchFrameLayout view, MotionEvent ev, boolean disallowIntercept) {
switch (ev.getAction()) {
case 0:
dayRecyclerViewClickHandler = true;
break;
case 1:
if(dayRecyclerViewClickHandler) {
dayRecyclerViewSetAdapter();
dayRecyclerViewClickHandler = false;
}
break;
default:
dayRecyclerViewClickHandler = false;
}
return false;
}
@Override
public boolean onTouchEvent(InterceptTouchFrameLayout view, MotionEvent event) {
return false;
}
});
In general it's a normal behavior to fire ACTION_MOVE events repeatedly even during still touches because of subtle noise arising in hardware level.通常,即使在静止触摸期间重复触发 ACTION_MOVE 事件也是一种正常行为,因为硬件级别会产生细微的噪音。 Rather, the device which doesn't fire the events may have a slightly lower grade touch-device (with low accuracy, low resolution or less responsiveness).
相反,不触发事件的设备可能具有稍低等级的触摸设备(精度低、分辨率低或响应能力低)。
You'd better adjust your code so that the app can work normally even if frequent extra ACTION_MOVE events (with nearly-zero movements) occur.你最好调整你的代码,这样即使频繁的额外 ACTION_MOVE 事件(几乎为零的动作)发生,应用程序也能正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.