I have an activity. Inside that activity I have implemented VerticalViewPager in which 3 pages are fed i.e. Upper Page, Middle page and Lower Page. Inside the middle page fragment and Lower page fragment I have separately another ViewPagers(Horizontal).Inside these ViewPagers I have 3/3 pages each. So far I have been able to make them working just fine i.e. on vertical swipe gesture the VerticalViewPager gets triggered and on horizontal swipe gesture native android ViewPager gets triggered. Now I need to sync the horizontal swipe transition between the middle fragment pages and lower fragment pages.
Let me give an example: say I have A,B and C pages inside middle fragment of VerticalViewPager and D,E,F inside the lower vertical fragment. Assume I am in the middle fragment now. So when I swipe from A to B left to right, the lower fragment should also swipe from D to E automatically.
[P.S.: For the horizontal(native) ViewPager to work inside
VerticalViewPager, the horizontal ViewPager Adapter needs to run
in the AsyncTask or threads. So please consider this scenario as
well]
You can make the adapter scope available globally and set the current view or fragment according to the change in the middle fragment.
According to the example:
Related
My Activity has a viewpager along with a tablayout. There are three tabs. Now while swiping between the tabs, there is noticeable delay (around 300ms) while i try to very quickly swipe from, say, the first to third tab.
Now the viewpager contains three fragments. I am using a FragmentPagerAdapter to declare the viewpager tabs (as this gave a slight improvement compared to when i used FragmentStatePagerAdapter). Also I have set offScreenPageLimit for the viewpager to 2 (since there are 3 tabs).
Now to find out what was going wrong, I initialised empty fragments for the tabs and the swiping was fine and smooth as expected.
Next, I implemented the full functional code for the middle/2nd tab and left the other two as empty fragment.
Now this is where things get interesting, I was expecting a small delay while i swipe into the middle fragment(it contains nothing but a listview), when it creates it views and plugs the adapter into the listview with data. However, that was not the case. There was a noticeable delay while swiping out of the middle fragment!
Thus I have reason to believe, that while swiping out, where the fragment's view is being removed from screen, there is something I need to take care of which will make the transition smoother.
Sorry, that title is a bit confusing. I've included a wireframe of my screen below.
A - a FrameLayout which acts as the header in the Activity and houses a Fragment
B - a SlidingTabLayout for the FragmentPagerAdapter in C
C - a FragmentPagerAdapter that houses Fragments with RecyclerViews (grids) as their layout
What I want to accomplish:
As the user scrolls through the grid RecyclerView in C, I want header A to scroll up and be hidden (similar to Material Design Toolbars being hidden on scroll). I also want the tabs in B to be locked on the top of the screen once A is completely hidden but I think that part would just follow easily as a consequence of accomplishing the scroll/hide on A.
Ideally, I'd like it to be a smooth scroll that matches the distance of the user's scroll. But my backup plan is to just have a slide-up animation in the A fragment that's triggered by a certain scroll magnitude in the C fragment (the trigger would be sent up through C's fragment listener interface - the parent activity).
I have a ViewPager with a FragmentPageAdapter set for it.
And the ViewPager is show some simple fragment.
I am able to use ViewPager for swipe between fragments.
However, I don't like the scrolling effect of ViewPager that showing partial content of next fragment while swiping/dragging current fragment.
Instead, I would like to switch to next fragment at instant with swipe(but without scrolling effect) and show fragment immediately.
How can I do such thing(must use ViewPagger)?
You have to implement your own "SwipeDetector" and use mViewPager.setCurrentItem(index, false) method (second parameter indicates whether to enable animation or not).
I want to make something like transitions between ViewControllers in iOS 7 but in Android, is it possible?
Explanation: please look at image below, I have main Activity which has ViewPager inside, so we can swipe between Fragments. I want to call another Activity (or Fragment) from each Fragment (blue on image) swiping to bottom or to top but this action should be done smoothly like in ViewPager.
You can intercept swipe up and down gestures and set items in viewpager accordingly. Please read this guide on how to intercept swipes in various directions.
I want Horizontal as well as vertical swipe using the ViewPager.I implemented it using the Vertical view pager in which I used the fragments for the vertical swipe and in that fragments, used ViewPager for the horizontal swipe.
I took help from below link for vertical swipe:
https://github.com/LambergaR/VerticalViewPager/
and http://manishkpr.webheavens.com/android-viewpager-as-image-slide-gallery-swipe-gallery/ for horizontal swipe.
Problem:
I have three image adapters and three fragments, one for each image adapter. These three fragments are inside one FragmentActivity. When this FragmentActivity is created I want to manually select which fragment should be displayed. Here, the three fragments contains data with three different languages. Now I want to load the fragment of particular language specified by the user. Any example or a code snippet will help me implement this functionality.
Thanks in advance :)