Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool SetNumberPickerTextColorAndSize(NumberPicker numberPicker, Color color, ComplexUnitType complexUnitType, float textSize, TypefaceStyle style)
- {
- int count = numberPicker.ChildCount;
- for (int i = 0; i < count; i++)
- {
- View child = numberPicker.GetChildAt(i);
- if (child.GetType() == typeof(EditText))
- {
- try
- {
- Field selectorWheelPaintField = numberPicker.Class
- .GetDeclaredField("mSelectorWheelPaint");
- selectorWheelPaintField.Accessible = true;
- EditText editText = (EditText) child;
- editText.SetTextSize(complexUnitType, textSize);
- editText.SetTypeface(editText.Typeface, style);
- editText.SetTextColor(color);
- Paint paint = (Paint) selectorWheelPaintField.Get(numberPicker);
- paint.TextSize = TypedValue.ApplyDimension(complexUnitType, textSize, numberPicker.Resources.DisplayMetrics);
- paint.Color = color;
- paint.SetTypeface(editText.Typeface);
- numberPicker.Invalidate();
- return true;
- }
- catch (NoSuchFieldException e)
- {
- Log.Warn("setNumberPickerTextColor", e);
- }
- catch (IllegalAccessException e)
- {
- Log.Warn("setNumberPickerTextColor", e);
- }
- catch (IllegalArgumentException e)
- {
- Log.Warn("setNumberPickerTextColor", e);
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement