I want to animate a view with SharedElement transition from one Fragment to another fragment in ViewPager.
I've 3 fragments in a ViewPager, each fragment is having a single TextView with same transition name in XML file.
Now, when ViewPager slides another Fragment, I want to see SharedElement in action.
I’ve had the same issue. Standard shared element transitions are not working between ViewPager pages.
So I wrote a Shared Element View Pager library. It works both for transitions caused by onClick() events (such as viewPager.setCurrentItem(x) ) and page slides caused by user. The animation is bound to finger movement.
It's not an android transition so there could be some obstacles. Take a look though.
SharedElementPageTransformer demo
ArrayList<Fragment> fragments = new ArrayList<>();
fragments.add(hello_fragment);
fragments.add(small_picture_fragment);
SharedElementPageTransformer transformer =
new SharedElementPageTransformer(this, fragments);
transformer.addSharedTransition(R.id.smallPic_image_cat, R.id.bigPic_image_cat);
viewPager.setPageTransformer(false, transformer);
viewPager.addOnPageChangeListener(transformer);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With