Skip to content
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

wrapSelectorWheel display glitch #111

Open
dvkch opened this issue Aug 25, 2018 · 5 comments
Open

wrapSelectorWheel display glitch #111

dvkch opened this issue Aug 25, 2018 · 5 comments

Comments

@dvkch
Copy link

dvkch commented Aug 25, 2018

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.

@philippeauriach
Copy link

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

@veritas1
Copy link

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.

@dvkch
Copy link
Author

dvkch commented Oct 16, 2018

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?

@anudeepreddygopu
Copy link

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

@wildanka
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants