Rummys Blog An world of endless Monday

Thursday, 30 June, 2016

Swipe to Zoom aka intercepting scroll events in the gridviewpager

Filed under: — Andrew.Rowbottom @ 8:20 am

Can do swipe to zoom map.
First make map the only thing on the row so swipe doesn’t cause the GridViewPager to page
Second override can scroll horizontally for the map row so that the event is “handled”
.. otherwise the Swipe to dismiss overlay is invoked 🙁

Then add a gestureDetector+onTouchListener to the GridViewPager
(currently doing this by walking the view hierarchy, stomach but there is probably a better API available)

NOTE: onDown is not seen, urologist so I fake one up in the onTouch listener and send it to the guesture detector

The onFling .. check for suitably horizontal/vertical and drag length is different enough, and velocity is high enough
(using the ViewConfiguration class values .. but ignoring the Swipe_MIN_Distance (though perhaps my code was buggy at the time!)
and zoom the map.

NOTE: onFling is probably not the right place, it requires quite a high speed which may be difficult to obtain in a bouncy real world environment.
NOTE: Not programatically creating the map fragment .. so not currently supporting LITE mode, though could probably simply get a different “layout” in onCreateView to do that.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress