android - combine horizontal viewpager with vertical viewpager - java

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

Related

Pass click event through levels of ScrollViews and Layouts

I have many ScrollViews with RelativeLayouts inside in one Activity all of them cover the whole screen. I got buttons in some of them but the problem is the top layout is blocking the click events for the other layouts.
I want it so if no button is hit at the first layout it passes the click event to next etc.
You may wonder why i have many layouts that covers the whole screen and that is because i got scrollviews in them to create a 3D paralax effect scrolling background with different layers.
On the top layer also have setOnDragListener if that is important.
Here i will try to show you how my setup is:
HorizontalScrollView1--Layout1--Images/Buttons
HorizontalScrollView2--Layout2--Images/Buttons
HorizontalScrollView3--Layout3--Images/Buttons
So right now ScrollView3 is taking all clicks because its in the front/top. I can't disable clicks on the Scroll cut it needs to be scrollable and there is also buttons at the top layer that needs to be clickable.
overriding this in the relativelayout and returning true makes the above routine redundant:
RelativeLayout slideLayout=new RelativeLayout(mContext){
#Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mIsMuteTouches) return true;
return super.onInterceptTouchEvent(ev);
}
};

Scrollable Views Interacting with other child views like Google street View

I intend achieving a layout similar to what is shown.
I have tried achieving similar behavior with Bottom sheet, percentFrameLayout, ScrollView and Coordinated layout on different occasions, but I've not being able to achieve something similar to the view that (possibly a fragment) that is scroll from the bottom of the screen and interact with other child views on the screen like the tab and the refresh button.
Any guideline and directions on how i can do this ?
You can use a RecyclerView for the cards and leave your toolbar and main content on a FrameLayout at the same level as the map. And of course a coordinator layout and proper behaviors on each element.
By doing this your recycler view will be able to interact with the toolbar and still be independent from the map.
In other words, you can reduce your problem to a single recyclerview scroll with a toolbar by making a space on the beginning of the vertical recyclerView.

Android ViewPager Detect Vertical Swipe

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.:)

Horizontal listview with OnScrollListener

I need sync scroll of 2 listViews (vertical and horizontal)
I tried several libraries for the horizontal listview, but no library implements OnScrollListener()
https://github.com/MeetMe/Android-HorizontalListView
https://github.com/sephiroth74/HorizontalVariableListView
https://github.com/dinocore1/DevsmartLib-Android
need this callback to scroll vertical list when scoll the horizontal list...
how can I do this?
Thanks!!
I did a little bit of code for this exact thing a while back. Check it out here https://github.com/slightfoot/android-tandem-scroll
Just duplicate https://github.com/slightfoot/android-tandem-scroll/blob/master/Library/src/com/demondevelopers/tandemscroll/TandemScrollView.java file and make it extend HorizontalScrollView.

Android implementing tabbed layout that you can swipe across

I am trying to implement a layout that looks like a tabbed view, but is it possible to implement it in such a way that if the user swipes horizontally, then it will switch to a different tab? A good example of this is the Google+ app for Android. In the streams Activity, there are three tabs (or subsections): Nearby, All Circles, and Incoming. Notice how when you swipe in one horizontal direction, the screen scrolls to the corresponding subsection. Is there a way to implement this?
You can achieve that with fragments and viewpager. you can use the things through android-support-v4 library. android-support-v4 library including the example matches your need.

Categories