Questions tagged [android-viewpager2]

ViewPager2 is the replacement of ViewPager, addressing most of its predecessor's pain-points, including right-to-left layout support, vertical orientation and modifiable Fragment collections.

New features

  • Comparing to its predecessor android.support.v4.view.ViewPager (VP1):
  • Right-to-left (RTL) layout support
  • Vertical orientation support
  • notifyDataSetChanged fully functional (VP1 bugs addressed)

API changes

  • FragmentStateAdapter replaces FragmentStatePagerAdapter
  • RecyclerView.Adapter replaces PagerAdapter
  • registerOnPageChangeCallback replaces addPageChangeListener

Known issues

  • clipToPadding
  • no fakeDrag
  • JavaDoc
  • nested scrolling parallel to orientation
  • no offscreen limit control
  • needs better TabLayout integration
  • no pageWidth setter (forced 100%/100%)
  • page transformer: no hardware/software layer choice; no reverse drawing order
  • keep current item visible when inserting a page before current
  • keyboard navigation needs work
  • FragmentStateAdapter stability / performance improvements coming

Useful links:

Official documentation

Official sample

Fundamental Stack Overflow answer

740 questions
-1
votes
1 answer

VIewPager2 using wrap_content instead of match_parent

I have a horizontal scrolling view pager. I set child items width to match_parent. But im getting them wrap_content instead. This view should be centred by gravity but parent's FrameLayout is cropped to child's width Items code:
Kostya1375
  • 99
  • 6
-1
votes
1 answer

Can't swipe on ViewPager2 only on one direction

I try to enable swipe in ViewPager2 only in ONE direction (to right). I has 5 pages. I try this in my activity: viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { override fun…
Alexei
  • 14,350
  • 37
  • 121
  • 240
-2
votes
2 answers

How to disable clicks on DotView?

I am using a custom view from here. I want to disable user interactions with the view pager 2 using this: binding.viewPager2.setUserInputEnabled(false); But, it moves when I click on a dot of that view. I tried to disable that using…
1 2 3
49
50