4

I'm working on a project for my thesis in which I'm using an app for analyzing swipe gestures. There are a lot of questions and informations around about the view pager in general and even how to manipulate its settings, but until now, I couldn't find the specific default value (distance between finger down and finger up) baked into the pager itself. This would be very useful for me in order to see what value google deems to be appropriate and to compare it to other values.

Help would be much appreciated! :)

edit:

OK, found some clues myself. This is the code for ViewPager: searchco.de/codesearch/view/10066260 and there is a static variable namend MIN_DISTANCE_FOR_FLING which has a value of 25 (dip). This value gets multiplied with the density of the current display, which is done in in initViewPager(). This value in turn is then used in determineTargetPage to check if the user has swiped a greater distance than the value. What I don't get: If I multiply 25 by e.g. 160 (as an exemplary density), the value gets way too big, so I'm obviously interpreting the code wrong in some way. I would really appreciate an explanation.

  • 1
    The value isn't multiplied with 160 it's multiplied with a scale factor which is the actual density of the screen divided by 160(the base density). For a screen with a density of 160 the scale factor will be 1, for a screen with a density of 240 the scale factor will be 240/160= 1.5 etc. See http://developer.android.com/guide/practices/screens_support.html – user Aug 12 '12 at 14:03
  • Ah, now I get it. Thanks a lot, that really helped! – user1593441 Aug 12 '12 at 14:10

2 Answers2

3

To sum this up in case anyone else needs the information (my thanks to @Luksprog):

The minimum threshhold for a sucessful swipe in a ViewPager is a non-device-specific constant which is 25dip, adjusted to the current device by multiplying it with a device-specific value, namely the scale factor of the device's display.

3

You need import ViewPager.php in your project (File -> Import -> General -> File System -> with path-to-SDK/extras/android/support/v4/src/) and disable mTouchSlop variable in initViewPager() block.

mTouchSlop = 0;//ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);

Then touch drag will be work immediately.