NumberPicker icon indicating copy to clipboard operation
NumberPicker copied to clipboard

wrapSelectorWheel display glitch

Open dvkch opened this issue 7 years ago • 5 comments

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.

dvkch avatar Aug 25 '18 15:08 dvkch

Seeing this as well. When changing the max Value, wheel appear as wrapped until scrolled.

philippeauriach avatar Sep 01 '18 12:09 philippeauriach

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.

veritas1 avatar Oct 15 '18 14:10 veritas1

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?

dvkch avatar Oct 16 '18 09:10 dvkch

This didn't fix my issue. I still get it when the values are refreshed.

anudeepreddygopu avatar Dec 03 '19 11:12 anudeepreddygopu

@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 = 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.

make sure that you already set app:np_wheelItemCount or via java/kotlin code. that fixed my problem

wildanka avatar Jun 23 '20 04:06 wildanka