Is there some way to show a small portion of the adjacent fragments while using the ViewPager in Android compatibility package.
The view that I want to make will show the current fragment in center and the edges of the fragments which are before and after the current one on either side.
I believe a ViewPager indicator would be the best solution available. Showing that there are pages to either side.
http://androidforums.com/application-announcements/391561-android-viewpager-indicator.html
Related
What I would like to achieve: Have a ViewPager with TabLayout where each Tab contains a new Fragment that has a RecyclerView layout out horizontally and managed by a FragmentPagerAdapter.
What I am struggling with: The default behaviour is that when you get end of the list on one of the tabs, it switches Tabs and snaps (snapping means if you pull over 50% of the viewport, it jumps to either direction). I want it to free-flow and not to snap. Sort of like how it happens in iOS by default.
I got inspired for this setup by the following two CodePath guide:
https://guides.codepath.com/android/google-play-style-tabs-using-tablayout
https://guides.codepath.com/android/ViewPager-with-FragmentPagerAdapter
How should I approach this problem (preferably without any other libraries)?
What I would do is use HorizontalScrollView instead of a ViewPager. The only caveat is that the view pager sends the lifecycle events to fragments as you scroll between them, whereas for HorizontalScrollView you will have to add them initially, and then they will be continuously active unless you manually change that. Also you may have an option to not use the fragments and use simple views depending on what you use the fragments for.
I would definitely not override the touch events for the ViewPager because it does some cleanup when it detects the UP motion, so just swallowing it is not a correct thing to do.
So I have a single activity that controls a viewPager and this viewPager controls five fragments. In one of the fragments, there is an ImageView.
I want this imageView transit to the next page when I do a swipe left. More specifically, the position of this imageView will transit as I am swiping and once the swiping is done and the next fragment layout is completely shown on the screen, this ImageView should be a fixed location in this layout.
Does anybody know how I can make this work?
Thanks!
I think I know what you mean. It might be easier to make it a separate View on top of the pager, perhaps disabled so drags will go through it. and then you need to get a live reading of the position of the page. onPageScrolled on ViewPager.OnPageChangeListener is pretty cool and gives you what you need to place elements or do other transitionary effects based on the actual position of the Views in your ViewPager.
In google play, if you enter a screen that uses tabs, you can notice how you can scroll each tab but the panel that seen to contain the tabs also moves vertically to a certain extent. I can imagine that it accomplishes the movement of the tab panel with a TranslateAnimation and a layout animations. But what I can't understand is how it decouples the content of the tab from the tab panel.
To answer the decoupling of the tabs and content question; I have implemented this before using 2 sets of tabs. One is in the content as a list header, the other is layered on top of the list in a containing FrameLayout so it's 'floating'.
Using scroll callbacks you can change the visibility of the floating tabs to suit your needs. Once the list header tabs moves off the screen make the floating tabs visible, once they move fully back onto the screen hide the floating tabs.
Just ensure that every time you show/hide tabs that you copy the values for horizontal scroll position and selected tab from the currently visible tabs to the ones that are about to become visible. works a treat.
The best open-source project you can find for this Android-ObservableScrollView
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 :)
I've been struggling with that for a while: Is it possible to force PageTitleStrip draw itself on the content of the ViewPager?
Here is the case:
The red line indicates the end of ViewPager content and the start of PagerTitleStrip. The brown background belongs to the hole activity. Blackboard and blue backgrounds are from fragments in pager. The screen is taken during scrolling so that 2 fragments can be seen. I want the icons from PagerTitleStrip to be displayed transaprently and party on the viewPager's content.
Any suggestions are highly appreciated.
I don't think it's possible to do this with the built-in ViewPager and PagerTitleStrip. You will have to make your own custom component based on these to get the effect you're looking for.