Android ViewPager Detect Vertical Swipe - java

I would like to allow the ViewPager to swipe normally to the right/left as it is and detect Vertical Flings. I tried to assign a GestureDetector but the problem is that returning true from the method public boolean onDown(MotionEvent e) disables the normal horizontal swiping of the ViewPager. Any ideas how to allow both?

There are already some custom controls for this. Try looking into these threads of how to implement a Vertical ViewPager.
http://vision-apps.blogspot.ro/2013/05/4-directions-swipe-navigation.html
How to put Vertically swiped ViewPager in a Horizontally swiped ViewPager
https://stackoverflow.com/questions/14889530/vertical-viewpager-implementation
Hope this helps.:)

Related

Android ViewPager2 scroll both vertical and horizontal

I am attempting to use a ViewPager2 with fragments, and I would like to be able to swipe both vertically and horizontally. I have tried implementing a GestureListener for detecting swiping, both on the ViewPager2 and on the fragments within, but neither are picking up the events. Is there some way to either detect swipes within a viewpager2, or have the orientation be both vertical and horizontal?

Three screens with vertical sliding ability

How is the best way to make three vertical screens with sliding between them, like ViewPager.
I want to show user middle screen with ViewPager for horizontal pictures sliding, and two screens for settings (top and bottom).
I tried to use ViewPager in ViewPager, but it's a bad solution for me.
Then ViewFlipper but could not make sliding between screens like ViewPager.
My last chance now is ViewDragHelper but I'm not sure.
Maybe somebody knows real example?

Android ViewPager Fragments - No Swipe and Preloading?

I have a pretty standard implementation of ViewPager using Fragments; however I'm wondering if it's possible to get rid of the preloading of tabs, and to only load a tab activity once user clicks on it?
Also, can we get rid of the swipe effect, just like in iOS?
Thank you
If you want the user to only click on tabs, then don't use a ViewPager; put the views in a FrameLayout, make them all invisible and only set the view that is selected visible. When the user clicks on a tab, make the current view invisible and selected view visible. Much simpler than implementing a PagerAdapter.

android - combine horizontal viewpager with vertical viewpager

I want to combine a default horizontal ViewPager with some kind of a vertical ViewPager. My approach would be that the Fragments provided by the horizontal ViewPager, are subclassing the vertical ViewPager.
public class SubWebViewFragment extends Fragment, VerticalViewPager {
}
Thus each Fragment provided by the horizontal ViewPager should at the same time act as a VerticalViewPager, building up some kind of a matrix. In addition I have to have the possibility to go to a certain page in this matrix. E.g. I want to select page 2 of the horizontal ViewPager, and of this page two I want to go to page three of the vertical ViewPager.
// pseudo code
HorizontalViewPager.setCurrentItem(1, true);
activeHorizontalPage.getVerticalViewPager.setCurrentItem(2, true);
I'm a bit lost on how to approach this issue.
I built a solution combining a horizontal viewpager (the parent) with vertical viewpagers (each child).
I overrode the following methods on vertical viewpager:
public boolean onInterceptTouchEvent(MotionEvent ev)
public boolean onTouchEvent(MotionEvent ev)
When the user triggers those events on each child, they pass it to the parent. Then, if the event is vertical, the child processes it, otherwise, if the event is horizontal, the parent processes it.
Take a look to my DoubleViewPager library, where I implemented this strategy.
This DoubleViewPager project on GitHub seems to have implemented a simple version of what you're asking for. He has a customized HorizontalViewPager and VerticalViewPager derived from the ViewPager class that allows for the page stack structure you're asking for.
Have you thought of using a listview instead of a vertical viewpager also try checking out theTwowayview library

Android - Custom ListView disable scrolling

I have a custom ListView which checks for a value in its adapter, and if its false it should disable scrolling. The reason I need to do this is because inside the listview are rows of horizontal listviews (using this implementation: https://github.com/dinocore1/DevsmartLib-Android) and if you scroll slightly up or down whilst scrolling on of these horizontal views, they stop scrolling and the listview instead scrolls.
The issue with this code is that it doesn't always seem to prevent the listview from scrolling, and it also doesn't pass the action through to the child (horizontal listview) like I believe it should (passing false).
Does anyone have any idea how I can get it to stop scrolling and still pass the movement action through to the child? Any help would be appreciated.
Thanks.

Categories