NumberPicker
NumberPicker copied to clipboard
wrapSelectorWheel display glitch
First of all, thanks for this library, I spent hours looking for something like this and it is great! That being said I have an issue with wrapSelectorWheel.
I use the NumberPicker to display a dynamic list of strings and wrapSelectorWheel is only applied after I the selected item has changed from user scrolling. Initially it shows a wrapped wheel, which can't be scrolled up, and after the user scrolls the wrapped items disappear. They reappear again after I change the inputs.
Here is the layout part:
<com.shawnlin.numberpicker.NumberPicker
android:id="@+id/optionsPicker"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:np_wheelItemCount="5"
app:np_textSize="17sp"
app:np_selectedTextSize="18sp"
app:np_textColor="@color/mediumGray"
app:np_selectedTextColor="@color/darkerBlue"
app:np_dividerColor="@color/lightGray"
app:np_dividerDistance="30dp"
app:np_dividerThickness="1dp"
/>
Here is the code changing the inputs:
optionsPicker.minValue = 0
optionsPicker.maxValue = options.size - 1
optionsPicker.displayedValues = options.toTypedArray()
optionsPicker.value = 0
optionsPicker.wrapSelectorWheel = false
I saw other issues on this and tried setting the property after I change the min/max values but the behaviour persists.
Seeing this as well. When changing the max Value, wheel appear as wrapped until scrolled.
I had the same issue. This can be fixed though, if you place optionsPicker.wrapSelectorWheel = false AFTER optionsPicker.maxValue = options.size - 1 and BEFORE optionsPicker.value = 0.
It has to be after setMaxValue() as that method overwrites the mWrapSelectorWheel flag.
That fixed it. Maybe what's done in setValue() that causes the view to refresh could also be done in setWrapSelectorWheel to circumvent this particular ordering?
This didn't fix my issue. I still get it when the values are refreshed.
@anudeepreddygopu I got the same issue, but I got something..
if you still experience the same problem after following this
I had the same issue. This can be fixed though, if you place
optionsPicker.wrapSelectorWheel = falseAFTERoptionsPicker.maxValue = options.size - 1and BEFOREoptionsPicker.value = 0.It has to be after
setMaxValue()as that method overwrites themWrapSelectorWheelflag.
make sure that you already set app:np_wheelItemCount or via java/kotlin code. that fixed my problem