How to get a continuous Touch Event?

后端 未结 7 1637
死守一世寂寞
死守一世寂寞 2021-01-17 14:01

My class extends View and I need to get continuous touch events on it.

If I use:

public boolean onTouchEvent(MotionEvent me) {

    if(me.getAction()         


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 14:14

    Use if(me.getAction() == MotionEvent.ACTION_MOVE). It's impossible to keep a finger 100% completely still on the screen so Action_Move will get called every time the finger moves, even if it's only a pixel or two.

    You could also listen for me.getAction() == MotionEvent.ACTION_UP - until that happens, the user must still have their finger on the screen.

提交回复
热议问题