We would like to create an app intro with animation where the user scrolls through pages and, as the user scrolls, a view is animated and travels through all the slides. The animated view should move as the user scrolls, so if the user scrolls faster the animated view should move faster and if the user scrolls back to a previous page, the animated view should move backwards.
This is super easy in iOS with https://github.com/IFTTT/JazzHands but I can't find a way to do this in Android.
Problems I've found:
- Animations run in real time; you can't let the time be the ViewPager offset.
- In
FragmentPagerAdapter
, views from one fragment can't be moved to another fragment.
Any suggestion? Thank you.
For the second problem:
The viewPagerAdapter will destroy the views when they are no more needed so to keep a view visible through all the pages you need add it to the layout that contains the ViewPager.
Something like this can works:
This is a partial answer. It's for the first problem.
I can change the properties of the animated view in the
onPageScrolled
method ofOnPageChangeListener
of theViewPager
.This is a simple example that changes the left margin of the animated view so it moves to the right.
The second problem is not solved, though. When the view reaches the right side of the page it is in, it disappears. In other words, the view can't move to the next page (fragment).