我如何感知用户是否将手指按住屏幕而不移动?
我目前正在使用纯 OpenGL 以我自己的方式绘制按钮。
我可以使用 onTouchEvent 检测按钮是否被按下,但我想知道用户是否按住按钮,或者用户是否不再触摸屏幕。
I am currently using pure OpenGL to paint buttons in my own little way.
I can detect if a button is pushed with onTouchEvent, but I want to know if the user is holding the button down, or if the user is no longer touching the screen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在初始 MotionEvent.ACTION_DOWN 事件之后,所有后续触摸事件(用户将手指保持在屏幕上)都将是 MotionEvent.ACTION_MOVE 事件,直到用户将手指从屏幕上抬起,这将注册为 MotionEvent.ACTION_UP 事件。
如果您想确保用户的手指仍然放在按钮上,请在 MotionEvent.ACTION_MOVE 事件期间进行边界检查,或者如果您不关心用户是否将手指从按钮上拖动,只需检查 MotionEvent.ACTION_UP 事件。
After the initial MotionEvent.ACTION_DOWN event, all of the subsequent touch events(user keeps finger on the screen) will be MotionEvent.ACTION_MOVE events until the user lifts their finger off of the screen which will register as an MotionEvent.ACTION_UP event.
If you want to make sure the user still has their finger on the button do bounds checking during MotionEvent.ACTION_MOVE events or if you don't care if the user drags their finger off of the button just check for a MotionEvent.ACTION_UP event.