We got a NumberPicker widget in 3.0, but it seems that the textSize for this widget can't be modified. Am I missing something or is this the case? I'd really like to increase the font size, it's quite small with the default value. But I can't see a textSize property for it.
I was able to accomplish this by extending the default NumberPicker. Not ideal, but it works.
public class NumberPicker extends android.widget.NumberPicker { public NumberPicker(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void addView(View child) { super.addView(child); updateView(child); } @Override public void addView(View child, int index, android.view.ViewGroup.LayoutParams params) { super.addView(child, index, params); updateView(child); } @Override public void addView(View child, android.view.ViewGroup.LayoutParams params) { super.addView(child, params); updateView(child); } private void updateView(View view) { if(view instanceof EditText){ ((EditText) view).setTextSize(25); ((EditText) view).setTextColor(Color.parseColor("#333333")); } } }
Then just reference this class in your layout xml.
<com.yourpackage.NumberPicker android:id="@+id/number_picker" android:layout_width="43dp" android:layout_height="wrap_content" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With