Bug P3
Status Update
Comments
gg...@google.com <gg...@google.com>
gg...@google.com <gg...@google.com>
nu...@gmail.com <nu...@gmail.com> #2
Can you attach / share a project that reproduces the issue?
nu...@gmail.com <nu...@gmail.com> #3
Now i sure this is viewpager2's bug.
because just occur recyclerview inside viewpager2 with constraintlayout, if paging3 use Independently with viewpage2 it's not problem.
because just occur recyclerview inside viewpager2 with constraintlayout, if paging3 use Independently with viewpage2 it's not problem.
Description
The ViewPager2 is set to offscreen page limit > 0 and TabLayoutMediator set to jump scroll (smoothScroll=false). When the user swipes left on first page to scroll to the second page, the tab indicator fails to snap to the tab for the second page and is stuck between the first and second tab. Further page swipes eventually result in the indicator snapping correctly, but if the user scrolls back to the first page, the behaviour is repeated and in some cases more pronounced (see video).
If offscreen page limit is set to ViewPager2#OFFSCREEN_PAGE_LIMIT_DEFAULT (-1) then normal behaviour is observed, i.e. the tab indicator snaps properly to the correct tab in the TabLayout. The indicator behaves as expected when tapping on tabs.
To recreate the problem:
Create ViewPager2 with associated TabLayout in XML layout.
Set ViewPager offscreen page limit to >0.
Provide tab titles of differing lengths with the longest first.
Attach TabLayoutMediator with smoothScroll = false.
Swipe left on first page to smooth scroll to second page.
Observe tab indicator stuck between tabs.
The problem is apparent on all versions of Android Studio emulator from KitKat (API 19) through to R (API 30) and is also reproducible on my Samsung Galaxy S5 physical device (API 23). I haven't tried earlier versions of Android.
Specific dependencies used:
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
Video emulator showing problem:
Source code used to reproduce problem: