timusus / RecyclerView-FastScroll

A simple FastScroller for Android's RecyclerView
Other
1.39k stars 183 forks source link

Rounds popup padding calculation to avoid size changes when the chara… #64

Closed G00fY2 closed 7 years ago

G00fY2 commented 7 years ago

…cter height only differs a few pixels. Fixes #63

Details: In the default Android Roboto font e.g. alphabetic and numeric characters height sometimes differ only a few pixels. The numbers '1,4,5,6,7' are smaller than '0,2,3,8,9'. This caused the popup width to change its size because the way the horizontal padding gets calculated by getting the vertical padding. I tried different ways to handle this behaviour (e.g. getting the max. font height by FontMetrics). But this did not look well in some situations ('Ä,Ü,Ö' vs 'o,u,n'). So in the end I found simple rounding (to nearest 5) to work best.