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 15 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 |
…humb size change on tap to open menu)
|
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. |
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
Removed calculation scroll thomb position and size based on RecyclerView.computeVerticalScrollRange() / computeVerticalScrollOffset(), because it depended on scroll position and recalculated while scrolling and made glitch.
This PR:
dy) instead of recalculating it from RecyclerView's estimated scroll offset on every layoutI also add the changed scroller to fix tags glitch.
How Has This Been Tested?
Manual UI test.
Before:
telegram-cloud-document-2-5373303824473696425.mp4
telegram-cloud-document-2-5377809133498049085.mp4
After
telegram-cloud-document-2-5379845175629623475.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.