Answer the question
In order to leave comments, you need to log in
How to recognize zoom gesture and other gestures on the same View in Android?
I have a TextView wrapped in a ScrollView. I want to hang several gesture detectors on this TextView in order to recognize different gestures on this View. In particular, I need ScaleGestureDetector (recognizes the zoom gesture) and GestureDetector (recognizes tap, double tap, long press and others). Listener to both detectors is done, I hang it on View OnTouchListener:
tw.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (!gestureDetector.onTouchEvent(motionEvent)) {
scaleGestureDetector.onTouchEvent(motionEvent);
};
return true;
}
});
tw.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
scaleGestureDetector.onTouchEvent(motionEvent);
return false;
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question