Reputation: 21
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 would like to support following operations:
Is this doable only with GestureRezognizer? If not, how to handle all those cases?
Upvotes: 2
Views: 5743
Reputation: 86
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();
}
return true;
}
More information about the MotionEvent object can be found on the Android Developers website.
Upvotes: 2