Is there a way to make a ViewPager
that does not scroll horizontally, but vertically?!
Android: Vertical ViewPager
androidandroid-viewpager
Related Topic
- Android – Activity restart on rotation Android
- Android – How to lazy load images in ListView in Android
- Android – How to close/hide the Android soft keyboard programmatically
- Android – unique Android device ID
- Android – How do disable paging by swiping with finger in ViewPager but still be able to swipe programmatically
- Java – Proper use cases for Android UserManager.isUserAGoat()
- Android 8: Cleartext HTTP traffic not permitted
Best Answer
You can use a ViewPager.PageTransformer to give the illusion of a vertical
ViewPager
. To achieve scrolling with a vertical instead of a horizontal drag you will have to overrideViewPager
's default touch events and swap the coordinates ofMotionEvent
s prior to handling them, e.g.:Of course you can tweak these settings as you see fit. Ends up looking like this: