I do not believe this is supported. I was thinking of a dirty way to do this manually:
You can use the NumberPicker scrollBy (int x, int y) function, called iteratively, to make the animation effect.
Some things to consider:
- scrollBy (x, y) works with pixels. Since Android has everything that differs from the screen density, what you have to do is first guess (I would do it with trial and error) the "dp" distance, which corresponds to scrolling to a sequential value, and convert it to pixels to use it.
- The first parameter, scrollBy (x, y), should be set to 0, if this is not obvious.
I didn’t do the animations myself on Android, but there is a very good API since Honeycomb, which probably makes it easier to do this.
Sorry, but this is the easiest I could think of!
EDIT: to convert from 'dp' to pixels:
private float pxFromDp(float dp) { return dp * this.getContext().getResources().getDisplayMetrics().density; }
What you will need to do is call scrollBy (0, pxFromDp (dp)) with different "dp" values until you get the exact number that moves NumberPicker one number. Once you get this value, you can create your own animation method, which when scrolling up through X numbers will scroll X times this distance dp.
Please ask again if you do not understand it completely :)
alfongj Nov 21 '12 at 20:19 2012-11-21 20:19
source share