I have a custom view that extends Android ScrollView. The direct child is a relative layout which has children that are clickable. I want to be able to:
What I have tried so far is (pseudo code):
public class CustomView extends ScrollView {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return super.onInterceptTouchEvent(ev) || mScaleDetector.onTouchEvent(ev);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
return mScaleDetector.onTouchEvent(ev);
}
private class ScaleListener extends
ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScale(ScaleGestureDetector detector) {
// Handle the scale..
return true;
}
}
}
I also tried different configurations for the onInterceptMethod such as first call the super and the return the mScaleDetector.onTouchEvent and so on.
I succeeded to intercept the scale or the click and scroll but not both.
Thanks, Daniel
The solution is to use:
@Override
public boolean dispatchTouchEvent(MotionEvent ev){
super.dispatchTouchEvent(ev);
return mScaleDetector.onTouchEvent(ev);
}
and not override onInterceptTouchEvent
and onTouchEvent
methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With