https://kotlinlang.org logo
Title
u

Utkarsh Tiwari

02/25/2022, 5:28 AM
Hi, any suggestions on how we can achieve this loopable pager/tab layout with
ScrollableTabRow
and
HorizontalPager
?
For pager, I was redirected to this sample which seemed like a hack with bounds at
Int.MAX_VALUE
w

Will Shelor

02/25/2022, 6:37 AM
I think the code linked in the sample seems reasonable. If you’re worried about someone scrolling too far you could have the selected value jump back around when it lands on an element above or below the threshold you’re expecting (that way you don’t need max_value, you just need a “dummy” page on the end that sent back to the first element when selected- I’ve seen both done before, and performance wise it shouldn’t make much of a difference).
:thank-you: 1
u

Utkarsh Tiwari

02/25/2022, 7:22 AM
you just need a “dummy” page on the end that sent back to the first element when selected-
Wouldn’t this cause a break or abrupt jump in the fluid animation of the view pager when the user is sent back from the right most page to the left most page?
w

Will Shelor

02/26/2022, 12:05 AM
you’d probably want to put it after landing, not when there was a chance of animation. I believe when I’d seen this before they had 2 pages in case the user overscrolled a bit.
🙆‍♂️ 1
u

Utkarsh Tiwari

02/27/2022, 11:28 PM
Thank you for sharing these ideas. Let me give them a try! 🙇‍♂️