Vertical swipe in ViewPager - android

I use ViewPager with PagerAdapter. Is it possible to implement vertical swipe in Android, where you can scroll between views from top to down and from down to top? I need identical behavior that ViewPager does by default, but in vertical way. I found method canScrollVertically() but it's not what I am looking for I suppose. Thanks in advance

Natively, no.
However, Jake Wharton has a directional ViewPager that does this.
https://github.com/JakeWharton/Android-DirectionalViewPager/
The only problem is he doesn't support it anymore, but it will get you started. It might even be enough for what you want.

Related

Swiping a SlidingPaneLayout inside a ViewPager

I'm trying to use a SlidingPaneLayout inside of a ViewPager. All I can find are solutions for the other way around, like Using Android's SlidingPaneLayout with ViewPager which doesn't work.
Is there something easy to change to allow the SlidingPaneLayout's edge to get priority over a ViewPager's? I don't know anything about handling touch events or I'd try to tackle it myself.
JFeinstein slideMenu project is referred to in this post - very similar to yours. The config for the inner view can be configured to consume the swipe from the edge of the bezel, before that event propogates to the ViewPager

Horizontal Carousel or ScrollView with text over image

I'm trying to figure out the best approach to design a horizontal scrollview from android >= 2.1 with some text over the image that when scroll if end is reached it starts showing the first items again hence carousel behavior.
You can continue scrolling horizontally, forever, and the first item shows up again when the end is reached, for example when scrolling swiping to the left. It can be a view pager with an adapter, a carousel but not horizontal scrollview as it does not support some android device.
Any suggestions would be greatly appreciated.
Why not use a ViewPager? As it is available in the Support Library. I would insist to use ViewPager instead of HorizontalScrollView or Gallery. You can check an example for ViewPager from my github.
UPDATE
To show multiple views inside a Fragment you can use getPageWidth(). Check here for reference.
For future people looking for this, here's an excellent library that fit my needs for a similar problem!
https://github.com/sparrow007/CarouselRecyclerview

How do I implement such a layout?

Photos in this layout can be swiped left and right, and swipe should be 'intelligent', like switching between photos and NOT like just horizontal scrolling of photos.
2 implementations that come to my mind:
HorizontalScrollView (but swiping is dumb)
ViewPager (but there is no way to see adjacent photos)
So, basicly I need a ViewPager for photos that can show adjacent photos.
Is there a robust solution for this?
For cool swiping action viewpager is the best. And you won't have problems with memory. BUT I have no idea how to make view pager part of listview.
If you have final number of items you can use Android Gallery widget which is deprecated since api 16 but does exactly what you need, the main problem is that it cant reuse gallery items inside the adapter.
You also can try this:
Horizontal list view
I have used TwoWayView to implement my layout.
It's better than HorizontalView, cause it re-uses views (like ListView).

HorizontalScrollView with snapping effect

Is it possible to make HorizontalScrollView with snapping effects for each view inside it?
(Not gallery)
Nowdays you should use ViewPager or RecyclerView.
Old answer:
I used this one - http://www.dev-smart.com/archives/34
Very fast and compatible with lazy loading.
You try to use ViewPager instead
Have a look at below posts for sample codes. Still, most use ViewPager for the effect.
http://androidprogrammingmadeeasy.blogspot.jp/2011/08/creating-custom-horizontal-scroll-view.html
http://www.velir.com/blog/index.php/2010/11/17/android-snapping-horizontal-scroll/

Viewpager horizontal scrollbar not showing up - Android-

In my viewpager Ive enabled horizontal scrollbar by such featuredPager.setHorizontalScrollBarEnabled(true);
However it never shows up or does anything
setHorizontalScrollBarEnabled is a method of View. It will not work as an indicator for the pages of a ViewPager. You can make your own View that does this, by listening using an implementation of ViewPager.OnPageChangeListener. However, there are already some libraries that can handle this for you, like this one. I would recommend you to try that first.

Categories

Resources