[ACCEPTED]-Android Touch event on screen-touch

Accepted answer
Score: 26

try this code

public boolean onTouchEvent(MotionEvent event) {
  // TODO Auto-generated method stub
  return super.onTouchEvent(event);


Score: 24

The problem you might have when using the 9 onTouchEvent() is that because of your view hierarchy 8 where you also have other views on top of 7 your activity, touches on views that override 6 this event (buttons, edittext etc) will 5 not go down to you activity anymore and 4 you will not receive them.

You should use 3 dispatchTouchEvent() instead as this propagates the other way 2 around, from the activity to your other 1 views and always gets called.

public boolean dispatchTouchEvent(MotionEvent ev) {
    // Your code here
    return super.dispatchTouchEvent(ev);

More Related questions