-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix scrollbar thumb size changing during scroll #19484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix scrollbar thumb size changing during scroll #19484
Conversation
Cache maximum scroll range to prevent thumb resizing when items with different heights scroll in/out of view. This ensures the thumb maintains a consistent size throughout scrolling.
|
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
mikehardy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neat idea! one quick question
| // Initialize cache on first layout if not set yet | ||
| if (cachedMaxScrollRange == 0 && currentScrollRange > 0) { | ||
| cachedMaxScrollRange = currentScrollRange | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary, or is this always just a special case if the conditional above that sets cached if current is > ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Removed the redundant initialization :) the condition above already handles it.
Cache maximum scroll range to prevent thumb resizing when items with different heights scroll in/out of view. This ensures the thumb maintains a consistent size throughout scrolling.
…7se7en72025/Anki-Android into fix/scrollbar-thumb-size-stable
mikehardy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait :-), now you removed both cache storage conditionals, so you won't cache the current range if it's greater than the cached range...
Add logic to update cached maximum scroll range to maintain thumb size consistency.
|
@mikehardy pls check now, Have made the correct changes !! |
AnkiDroid/src/main/java/com/ichi2/anki/ui/RecyclerFastScroller.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Mike Hardy <[email protected]>
|
@BrayanDSO @mikehardy pls check now |
|
Don't ping people that fast. Be patient. Everyone here has other things to do. |
mikehardy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 seems good now, and does seem like this trick should work
Thanks!
david-allison
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open Card Browser or Tags Dialog
This doesn't appear to change anything on the Tags Dialog
Just tested and the scrollbar now jitters
AnkiDroid Version = 2.23.0alpha8-debug (dcf793c)
Screen_recording_20251115_214207.webm
Fix the scrollbar thumb height calculation to prevent jittering during scroll. Changes: 1. Cache the maximum scroll range to prevent thumb size changes when items with different heights scroll in/out of view 2. Fix handle height calculation to use computeVerticalScrollExtent() instead of barHeight in the numerator. The correct formula is: (visibleExtent / totalRange) * trackHeight Previously used (barHeight / range) * barHeight which was mathematically incorrect and didn't properly represent the proportion of visible content. Fixes ankidroid#19224
…7se7en72025/Anki-Android into fix/scrollbar-thumb-size-stable
Fix the scrollbar thumb height calculation to prevent jittering during scroll. Changes: 1. Cache the maximum scroll range to prevent thumb size changes when items with different heights scroll in/out of view 2. Fix handle height calculation to use computeVerticalScrollExtent() instead of barHeight in the numerator. The correct formula is: (visibleExtent / totalRange) * trackHeight Previously used (barHeight / range) * barHeight which was mathematically incorrect and didn't properly represent the proportion of visible content. Fixes ankidroid#19224
Cache computeVerticalScrollExtent() and only update when RecyclerView is resized. The visible extent can vary during scroll, causing the thumb height to change and create jitter. Changes: - Add cachedVisibleExtent and lastRecyclerViewHeight variables - Only recalculate visible extent when RecyclerView height changes - Use cached visible extent for handle height calculation - Reset cache when adapter changes This prevents the thumb size from changing during scroll, eliminating the jitter issue.
Cache the calculated handle height and only update when there's a significant change (> 2px difference). This prevents small calculation fluctuations from causing jitter during scroll. Changes: - Add cachedHandleHeight and cachedBarHeight variables - Only update handle height if barHeight changed or difference > 2px - Use cached handle height to prevent jitter - Reset cache when adapter changes This provides additional stability on top of the visible extent caching.
11ab287 to
53c89c0
Compare
|
I wasn’t aware of your recent commits. If they fixed the issue, can I remove my commits i made after yours ? Please guide me. Thanks! |
- Set fixed row height (56dp) in card browser to prevent scrollbar jitter - Add ellipsize/line limits and improved styling to browser columns - Add ellipsize to note type field & tag list layouts - Add long-press toast + tooltip to view full text for truncated items Adds UX hints for truncated text and preserves smooth scrolling across lists.
9a70fc9 to
8e4164d
Compare
|
This doesn't compile I haven't made relevant commits to this issue on |
WhatsApp.Video.2025-11-17.at.02.28.04_bd1a91ab.mp4can something like this work ? |
|
That's already done by 'Options => Truncate content' |
|
then i will look for a way to fix this without truncating then, |
|
Converted to draft to remove from my queue, please mark it as ready when reviewable |
Purpose / Description
Fix scrollbar thumb size changing during scroll when RecyclerView items have different heights.
The scrollbar thumb was resizing as items with varying heights scrolled in/out of view. This occurred because
computeVerticalScrollRange()returns different values during scroll when items have different heights, causing the thumb height calculation to fluctuate.Before: Scrollbar thumb size would change while scrolling through items with different heights (e.g., tags with varying lengths, cards with different amounts of text).
After: Scrollbar thumb maintains a consistent size throughout scrolling, providing a stable and professional user experience.
Fixes
Approach
cachedMaxScrollRangevariable to cache the maximum scroll range encounteredThis ensures the thumb size is based on the true maximum content height we've seen, not the fluctuating current value that changes as items with different heights scroll in/out of view.
How Has This Been Tested?
fullDebugvariant using.\gradlew.bat installFullDebugTest Configuration:
Reproduction Steps:
Learning (optional, can help others)
The issue occurs because RecyclerView's
computeVerticalScrollRange()can return varying values as items with different heights scroll in and out of view. This is a known limitation when dealing with dynamic item heights in RecyclerView.Research:
computeVerticalScrollRange()calculates based on currently measured itemsRelated:
RecyclerFastScrollerChecklist
Please, go through these checks before submitting the PR.