Friday, March 31, 2017

Is there a way to hide the upper and lower values in a NumberPicker

Leave a Comment

I want to use this NumberPicker (as the default one is not much customizable), but I want to hide the upper and lower level, showing only the center row...is this possible? I also tried to remove the fadingEdges but, as I read, it's a deprecated attribute; even overScrollMode doesn't work

1 Answers

Answers 1

I want to hide the upper and lower level, showing only the center row...is this possible?

Looking at the source code, there are several things you could try. The easiest would be to change the following constant to 1, since it controls the number items displayed in the selector 'wheel':

private static final int SELECTOR_WHEEL_ITEM_COUNT = 3; 

If that doesn't work, you could modify the drawing routine to skip over any index that isn't in the center row. You'll want to look at lines 1468 - 1482.

I'm not sure what you're trying to say about the fading edges, but if you're trying to remove them, it could be as simple as returning 0 in these two methods, at lines 1426 - 1434:

@Override protected float getTopFadingEdgeStrength() {     return TOP_AND_BOTTOM_FADING_EDGE_STRENGTH; }  @Override protected float getBottomFadingEdgeStrength() {     return TOP_AND_BOTTOM_FADING_EDGE_STRENGTH; } 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment