Touch Events And Gestures In Surface View
Can anybody point me to some classes or suggest anything for the following case? I have SurfaceView which has a background image, on top of which I wish to paint other bitmaps. I w
Solution 1:
To handle touch input, override onTouchEvent in your class that extends SurfaceView to handle a MotionEvent. Here is a sample code that gets the screen position when a user first touches the screen.
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
touchX = event.getX();
touchY = event.getY();
}
returntrue;
}
More information about the MotionEvent object can be found on the Android Developers website.
Post a Comment for "Touch Events And Gestures In Surface View"