How to use PagerTitleStrip in ViewPager2?
Asked Answered
M

2

6

I have a standard implementation of PagerTitleStrip in ViewPager but it cannot work in ViewPager2. If I want to migrate to ViewPager2, how should I implement PagerTitleStrip within ViewPager2? I found solution and many detailed info regarding how to implement PagerTabStrip behaviour using TabLayout but it is not applicable to PagerTitleStrip.

Mistranslate answered 9/4, 2020 at 14:8 Comment(1)
Did you find the answer?Dolorous
P
0

ViewPager2 based on RecyclerView and implement only a limited subset of old ViewPager features.

Currently you cannot properly use neither PagerTitleStrip nor PagerTabStrip with ViewPager2.

Frankly I don't even know usecase where TabLayout with custom themed tabs and indicator and, maybe, some little extra code won't suffice.

Thus the only solution for ViewPager2 as for now is to use TabLayout.

Maybe if you will ask a question in context of your usecase or needed design - there will be a more detailed answer.

Hope it helps.

Phallicism answered 14/4, 2020 at 15:50 Comment(1)
"TabLayout with custom themed tabs and indicator and, maybe, some little extra code won't suffice." How isn't that a problem? I wanted to switch to ViewPager2 because it is simplier and more powerful, so it defeat the whole purpose of the migration.Cathar
D
0

Currently ViewPager2 has many bugs, that should be fix may be in future. while i was working on same i also found a bug and because of that i am unable to use ViewPager2 properly. For now it should be good if you use ViewPager only and avoid to use ViewPager2 for some time. Or the suggestion of Paul Ost is also good and acceptable.

Dittany answered 19/4, 2020 at 6:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.