开发者

How can I sense if the user is holding down their finger on the screen without moving it?

开发者 https://www.devze.com 2023-01-15 10:45 出处:网络
I am c开发者_JAVA技巧urrently 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,

I am c开发者_JAVA技巧urrently 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消