5

I've created a number picker with some string values.

public void setValues() {
    boolean defaultAvaliable = false;
    int defaultRow = 0;
    String[] values = new String[pickValues.size()];
    for (int i = 0; i < pickValues.size(); i++) {
        if (pickValues.get(i).equals("01:00")) {
            defaultAvaliable = true;
            defaultRow = i;
        }
        values[i] = pickValues.get(i);
    }

    timePicker.setMaxValue(values.length - 1);
    timePicker.setMinValue(0);
    timePicker.setWrapSelectorWheel(false);
    timePicker.setDisplayedValues(values);

    if (defaultAvaliable) {
        timePicker.setValue(defaultRow);
    }
}

And when I scroll to edge values (first or last) the picker first jumps to that item in a weird, not smooth way and after that when i try to go back to other values it doesn't scroll. The picker glitches on the edge value and after some time it finally goes back. In some way it looks like I would scroll over the edge value and it needs some scrolling to get back.

Has anyone else had this problem or does anyone have any suggestions what to check?

EDIT 1:

So I've got to he point that I know the problem is when I change the font size in my numberpicker, and don't know why. As soon as I set the font size over 39 it starts to get stuck on first and last item.

private void updateView(View view) {
    if(view instanceof EditText){
        ((EditText) view).setTextSize(39);
        ((EditText) view).setTextColor(getResources().getColor(R.color.mp_white));
        ((EditText) view).setFocusable(false);
    }
}

Does anyone know what is the row size? Or if I have to change the size of it, so it detects the scrolling correctly?

schmru
  • 501
  • 1
  • 9
  • 23
  • Hey, did you solve that issue? – nimi0112 May 24 '19 at 05:12
  • It may no longer be relevant at this time but you are correct, setting a higher text size is the cause of the scrolling issue. I ended up having to change the picker's height to a fixed size rather than "wrap_content" to get around that issue. – fab327 May 11 '20 at 22:48

0 Answers0