androidandroid-number-picker

How to decrease padding in NumberPicker


How to decrease padding in NumberPicker

enter image description here

I want something like it:

enter image description here


Solution

  • It's surprisingly easy to archive:

    enter image description here
    (scaleX and scaleY equals 2.5)

    enter image description here
    (without scaleX and scaleY)

        String[] values = {"Public", "Shared", "Private",....};
    
        NumberPicker np=
                (NumberPicker) findViewById(R.id.numberPicker);
        np.setMaxValue(values.length-1);
        np.setMinValue(0);
        np.setDisplayedValues(values);
    

    And simply set small layout_height and scaleX, scaleX:

    <NumberPicker
        android:id="@+id/numberPicker"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:scaleX="2.5"
        android:scaleY="2.5"/>
    

    I do agree, that standard NumberPicker is hardly customizable, though.

    I hope, it helps