Create HorizontalScrollView moving on swipe gestures - android

I have no idea how to implement a HorizontalScrollView that scrolls on swipes. And it should scroll to specific position. The positions are one the picture. The first one is how it appears from the beginning. Then when you swipe right, the scrll view slides to the beginning and number appears. Then when you swipe left you come back to the first position. And after swipe left from the first position, scroll view scrolls to the end and shows sharing options.

I think this should be implemented with ViewPager rather than Horizontal ScrollView.
Take a look to the official documentation

Related

Infinite viewpager with only one item for Android

How to create an infinite viewpager, but with only one view? For example, I want to scroll the view to the left, then update it and show the same view from the right. I need to see cool animation, with dragging view under the finger, not just to detect the gesture and slide out. I also need to understand in which direction the scroll happened.
Please help!

Conflict between recyclerview scroll and viewpager swipe

In my app I have a ViewPager that has four fragments. All the fragments are composed of RecyclerView which can be scrolled vertically. My problem is that when I try to navigate to other fragments and swipe left or right, the RecyclerView's scroll is detected first (mostly) and instead of going to other fragments the RecyclerView gets scrolled.
To be more clear, if I scroll the recyclerView, then suddenly swipe left or right, the viewpager never swipes.
What should I do?
When you scroll your RecyclerView vertically and cross a threshold to trigger scrolling, it consumes the TouchEvent. This means the default behavior is until you release your finger from the screen, the ViewPager will not be able to trigger a horizontal scroll. This is default behavior for how scrolling views interact with each other. You could attempt to override touch handling by extending RecyclerView and ViewPager or having a coordinating view that dispatches all TouchEvents to both views. However, either of these approaches could present a number of issues.
If you were to look at the Play Store for reference, its touch handling works the same as what you are seeing here.

how to control Android ScrollView to go all the way to top or bottom but never middle?

I have a fragment with a scrollview that holds a long layout essentially representing 2 different sections that are related, what I want is to control the scrollview so when the user wants to scroll down it always goes all the way down and can never be in the middle so it will never reveal partially the top or bottom parts, same effect backwards when you want to scroll up it just takes over and goes all the way up to reveal the top section of the layout fully.
It is basically how a vertical viewpager will behave but contained within a single long view.
I know how to programatically scroll up or down but I don't know how to avoid the user scrolling to just the middle, I'd like to hook up to some scroll event, detect the direction and go fully in either direction.

How to create an infinite carousel horizontal scroll bar in android?

In my android app, I have a horizontal scroll bar, and I can scroll all the way to the left and right. Go too far and you can't scroll anymore.
How can I change it that, you can keep scrolling left or right for as long as you want. Basically when u see the last thing in the horizontal scroll, then if you keep scrolling, you see the first item, and it loops like this. Similarly if you scroll to the left after seeing the first item, you see the last item.
Is this possible to do in android?
Thanks

ViewPager in a ListView - how to lock the scrolling axis?

I have a ViewPager widget in every row of a ListView. This provides a shelf-like UI, so the user can scroll around searching for a shelf vertically, and then scroll horizontally amongst the contents of a shelf. This works.
But the scrolling experience is terrible: if I start to drag a shelf's ViewPager, scroll it horizontally, and accidentally drag a bit upwards/downwards, then the ListView "traps" this dragging action, and start to scroll vertically, ending my horizontal drag. In this state, the drag action won't "return" to the ViewPager, the ListView has it, and that's it. I have to start another drag action to affect the ViewPager again. So I guess the ListView has precedence in these cases.
How can this be fixed? I'd like to achieve the exact opposite: If the ViewPager inside a list row starts reacting to a horizontal drag, then it should trap that action, and this drag should stop affecting the ListView, no matter how the user moves his/her finger vertically. Can this be done?
I've found a solution in this thread. There the problem is to handle touch events properly for a HorizontalScrollView inside a regular ScrollView, but the solution to that problem seems to apply to this one too.

Categories

Resources