Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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

like image 889
basteez Avatar asked Apr 02 '13 17:04

basteez


1 Answers

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;
}
like image 98
MH. Avatar answered Oct 25 '22 22:10

MH.