I want to get fling
gesture detection working in my Android application.
What I have is a GridLayout
that contains 9 ImageView
There's some proposition over the web (and this page) to use ViewConfiguration.getScaledTouchSlop() to have a device-scaled value for SWIPE_MIN_DISTANCE
.
getScaledTouchSlop()
is intended for the "scrolling threshold" distance, not swipe. The scrolling threshold distance has to be smaller than a "swing between page" threshold distance. For example, this function returns 12 pixels on my Samsung GS2, and the examples quoted in this page are around 100 pixels.
With API Level 8 (Android 2.2, Froyo), you've got getScaledPagingTouchSlop()
, intended for page swipe.
On my device, it returns 24 (pixels). So if you're on API Level < 8, I think "2 * getScaledTouchSlop()
" should be the "standard" swipe threshold.
But users of my application with small screens told me that it was too few... As on my application, you can scroll vertically, and change page horizontally. With the proposed value, they sometimes change page instead of scrolling.