ShawnLin013 / NumberPicker

:slot_machine: The android library that provides a simple and customizable NumberPicker.
MIT License
1.07k stars 240 forks source link

Fixed on click scroll when selected text size and general text size are different #192

Open thirstycoda opened 3 years ago

thirstycoda commented 3 years ago

Hi,

Thanks for this library. It has been a great help. I have however had 1 small problem when using the following settings: np_selectedTextSize = 70sp np_textSize = 30sp np_wheelItemCount = 7 np_orientation = horizontal

Tapping the selected number causes the picker to decrement and tapping the first number to the right of the selected number causes no scroll.

I believe the cause is the line int selectorIndexOffset = (eventX / mSelectorElementSize) - mWheelMiddleItemIndex;

If I understand the code correctly, it is assuming all elements are a similar size as it is using the size of the selector to determine which index has been tapped. If the selector element is bigger due to the the selector text size being bigger, the result of this will not be accurate.