Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewPager2 - slight disappointment. #252

Open
recodyx opened this issue Jan 21, 2023 · 2 comments
Open

ViewPager2 - slight disappointment. #252

recodyx opened this issue Jan 21, 2023 · 2 comments

Comments

@recodyx
Copy link

recodyx commented Jan 21, 2023

ViewPager2 is definitely not an improvement over ViewPager from my point of view.

Sorry I'm migrating from ViewPager right now and it's terrible.

  1. since always the method to add a listener was called add/setXXXListener. Now it's called registerXXXCallback. What's the point? Just wanted to be different?
  2. the "OnPageChangeCallback" is not an interface but an abstract class. WHY? God in heaven, why? This is a disaster. My fragment used to implement interface. Now I have to create a class, which I then have to connect to fragment somehow.... Custom ListenerInterface....
  3. now need TabLayoutMediator to link TabLayout with ViewPager2... why not just viewPager.attach(tabLayout) or something. Or why not do it the old way, when the TabLayout was part of ViewPager in layout xml, and thus linked.

Overall our code has become much more complex and less readable. Too bad.

@damon-beaven
Copy link

I agree. The last I checked ViewPager2 does not support instantiateItem(). I have places in my codebase where I have opted to keep ViewPager b/c of issues like this. For example, you will need instantiateItem() in your fragment's onMapSharedElements() if you are going to set a transition animation into an element that is in a ViewPager. You can't do this w/ ViewPager2.

@calsurferpunk
Copy link

I agree 100%. I couldn't stop getting:
java.lang.IllegalStateException: Page(s) contain a ViewGroup with a LayoutTransition (or animateLayoutChanges="true"), which interferes with the scrolling animation
No matter what I updated, it would constantly crash. Even setting setAnimateParentHierarchy(false) on any ViewGroup proved useless. I don't know how they could deprecate ViewPager for something so buggy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants