How to stop receiving the x, y coordinates of motion events when finger leaves the current view in Android? -


enter image description here

i have set ontouchlistener on blue part of screen. obtain x,y coordinates when finger touched on it. white part not @ all. problem if @ beginning finger touched on blue part , when "moves out" white part, still continuing obtain x, y coordinates. ideally want device stop detecting motion event finger leaves screen. hope can help.

the easiest solution check if finger touching view comparing x,y coordinates views bounding rect. can stop receiving events returning false dispatchtouchevent then.

edit:

@override public boolean dispatchtouchevent(motionevent event) {     rect outrect = new rect();     getdrawingrect(outrect);     if (outrect.contains((int) event.getx(), (int) event.gety())) {         return true; // want more events     } else {         return false; // stop events until next action_down on me     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -