Tuesday, January 27, 2015

Gesture detection and scrollview issue

In one of my latest application when I implemented ViewFlipper with gesture listener, I come across a strange issue. All child of ViewFlipper are scrollViews. I implemented simple gesture listener like when swipe to left or right will take to the next scrollView. But the issue was swipe functionality is not working in scrollView. If the ViewFlipper child are any other layout like Linearlayout, swipe functionality is working fine. As usual, I debugged and found that, we have to override the dispatchTouchEvent(MotionEvent e) of activity class.

The dispatchTouchEvent() will look like this,
public boolean dispatchTouchEvent(MotionEvent ev) {
super.dispatchTouchEvent(ev);
return gestureDetector.onTouchEvent(ev);
}
Where gestureDetector is an instance of android.view.GestureDetector class.

Reference:
http://stackoverflow.com/questions/8330187/gesture-detection-and-scrollview-issue

No comments:

Post a Comment

Androidians