How to decrease padding in NumberPicker

comalex3 picture comalex3 · Jan 4, 2016 · Viewed 10.3k times · Source

How to decrease padding in NumberPicker

enter image description here

I want something like it:

enter image description here

Answer

Konstantin Loginov picture Konstantin Loginov · Jan 10, 2016

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