Fix scroll thomb length changing on cards /tags lists of different size rows on bug#21367
Fix scroll thomb length changing on cards /tags lists of different size rows on bug#21367amoniaka-knabino wants to merge 18 commits into
Conversation
sanjaysargam
left a comment
There was a problem hiding this comment.
Thanks @amoniaka-knabino
Consider squashing the documentation and refactor commits for cleaner history
| private var cachedHandleHeightItemCount = RecyclerView.NO_POSITION | ||
| private var cachedHandleHeightBarHeight = 0 | ||
|
|
||
| private fun resetCachedHandleHeight() { |
| handle.layout(handle.left, y.toInt(), handle.right, y.toInt() + calculatedHandleHeight) | ||
| } | ||
|
|
||
| private fun getCachedHandleHeight( |
| <RelativeLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:layout_height="match_parent" |
There was a problem hiding this comment.
This wrapper needs to fill the available list area because it now contains both the RecyclerView and the overlay fast scroller. Keeping wrap_content would size the wrapper from its children instead of the available viewport, so the scroller track could end up with the wrong height.
|
|
||
| tagsArrayAdapter = TagsArrayAdapter(tags) { binding.root.showMaxTagSelectedNotice(tags) } | ||
| binding.tagsList.adapter = tagsArrayAdapter | ||
| binding.tagsList.attachFastScroller(R.id.tags_scroller) |
There was a problem hiding this comment.
What is scroller ID is not found ? It may crash
worth adding a null safe
There was a problem hiding this comment.
Good point, thank you. I made attachFastScroller null safe
@criticalAY Thank you for the patch! I tested it, because of smaller scroll thomb size, position looks more glitchy after the patch (please look at videos below, especially the cards video). How do you think, it's OK or we need to change it somehow? telegram-cloud-document-2-5380060933311732952.mp4telegram-cloud-document-2-5380060933311732950.mp4 |
|
@criticalAY I tried your second patch as it is, but glitch still was there. After I added accumulatedScrollOffset and it gets better. Position is smooth everywhere except start: scroll thomb "jumps" to start position when you scroll from end to start, but it's not really irritating, I think. after patch 2: telegram-cloud-document-2-5379845175629623469.mp4after accumulatedScrollOffset: (scroll jump at 0:22) telegram-cloud-document-2-5379845175629623475.mp4 |
|
The scrolling in this last recording looks really nice, but:
If it's not too much to ask, consider also testing the effects of this code on #20994. You can use the same deck I shared in #19480 (comment) to test both issues (make sure to import with scheduling information to get the flags; they help see the other issue). |
|
@amoniaka-knabino Can this be rebased? Or if you are not sure how then I can help here, just let me know |
Thank you for noticing! I will try to fix it. As I see, current version works OK on this collections, except scrolling in the end. At least, I can't see glitch and size changing while opening the editor on such small scroll thumb size. telegram-cloud-document-2-5382096975443304703-compressed.mp4telegram-cloud-document-2-5382096975443304705-compressed.mp4telegram-cloud-document-2-5382096975443304708.mp4telegram-cloud-document-2-5382096975443304707.mp4 |
|
The problem at the ends is worse with this bigger deck. Also, for the other issue, you need to grab the scrollbar thumb and slowly drag it. |
|
@ZornHadNoChoice I added scroll calibration and it become smooth. 2026-07-15.16.11.14-compressed-under-10mb.mp4UPD: I also tested grab&drag, it still have jump in the end. I'll see what can I do with it. telegram-cloud-document-2-5384348775256988729.1.mp4 |
|
It's definitely much smoother, but the thumb moves slower at the lower end. |
Thumb moves slower at the lower end because of calibration. It's hard to be fixed, because in the beginning of the scroll we don't know exactly height of all rows, so our scroll size and speed is not really precise. When we are close to end but still not at the last point, we recalculate scroll speed to let scroll thumb move until we really scroll to the last element. |
…humb size change on tap to open menu)
a1619ba to
8606f14
Compare
|
Hi @ZornHadNoChoice @criticalAY @sanjaysargam ! I fixed things that you wrote to me in the comments and now I am satisfied with current scroll thumb performance. I hope this version of fix is final and can be merged. You can see current version performance in the description of PR. |
Purpose / Description
Fix scroll UI bug: before length changed while scrolling list of rows of different length and looked glitchy, I want to make it smooth for better view.
Fixes
Approach
RecyclerView.computeVerticalScrollRange()andcomputeVerticalScrollOffset()are estimates based on currently visible rows. With variable-height rows, these estimates can change while scrolling, which causes the scrollbar thumb to resize or jump.This PR:
dy)attachFastScroller()a safe no-op when the requested scroller is not present in the layoutHow Has This Been Tested?
Manual UI test.
Before:
Current main performance.
telegram-cloud-document-2-5397669861138671532.mp4
After
Current branch performance.
FILE.2026-07-19.13.30.59-compressed.mp4
Learning (optional, can help others)
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem
Checklist
Please, go through these checks before submitting the PR.