8

I'm trying to decrease the size of an Android numberpicker, but already tried several things and I could not. I did not find a responsible attribute the change in size. Wanted to do the following:

enter image description here

Must decrease because I have to put the numberpicker on a screen with lots of information. Any help will be appreciated.

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
Jefferson
  • 307
  • 1
  • 5
  • 12

3 Answers3

9

I was facing a similar problem, I wanted to increase the text size of the NumberPicker but couldn't find a way to do it as part of the Widget. In my research I found the following solution:

<NumberPicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scaleX="0.75"
    android:scaleY="0.75"/>

Think of scaleX and scaleY as a magnifying factor. Values < 1 will shrink the Widget, 1 will have no change, and > 1 will increase its size.

Shah
  • 240
  • 1
  • 5
  • 7
4

Number Picker is quite not straight forword to modify or customize. Below is code which will adjust the NumberPicker height to 360dp actual values are considered match parent or wrap content in height will not be considered.

Text color,Text size,divider color can be changed as per style mentioned below

Height and style of number picker:

<NumberPicker
  android:id="@+id/np_month"
  android:layout_width="wrap_content"
  android:layout_height="360dp"
  android:theme="@style/AppTheme.Picker" />

Style:

  <style name="AppTheme.Picker" parent="Theme.AppCompat.Light.NoActionBar" >
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:textSize">40sp</item>
        <item name="colorControlNormal">@android:color/transparent</item>
    </style>
Vinayak
  • 6,056
  • 1
  • 32
  • 30
1

You may change directly on XML properties.

<NumberPicker
         android:id="@+id/numberPicker"
         android:layout_width="wrap_content"
         android:layout_height="90dp"
          android:orientation="vertical" />