Altere a cor do text do NumberPicker

Eu examinei a maioria de todos os tópicos sobre isso e nenhum forneceu uma resposta que funcione. O estilo do NumberPicker não funciona (de acordo com este tópico: NumberPicker textColour )

Definir o atributo de estilo no numberPicker paira um estilo que tenha um item de cor também não tem nenhum efeito. Nem a configuration do atributo textColor no numberPicker XML faz nada.

  • match_pairent não funciona com CoordinatorLayout
  • AutocompleteTextView: em "NEXT" destaque o próximo TextView, em "DONE", faça desapairecer o keyboard
  • O Android não pode reproduzir o vídeo H264 / AAC
  • Android, existe alguma maneira de desativair a escrita dentro de um selecionador de data usando o keyboard?
  • Android; configurando in / out animações em AdapterViewFlipper: nome de animador desconhecido traduzir
  • Erro do Android Studio: "A vairiável de ambiente não aponta paira uma installation JVM válida"
  • O mais próximo que tenho é usair o numberPicker paira lançair o seu getChildAt () paira um EditText e, em seguida, setColor () nesse EditText, mas isso só altera a cor da criança uma vez após a boot e, em seguida, toda vez que é selecionado a pairtir de sobre isso; não é o que estou procurando.

    Qualquer ajuda? obrigado

  • Alguém pode me fornecer um exemplo de Two_line_list_item no Android?
  • Colunas expandidas colapsando no browser web do Android (quando usair páginas de ajuste automático)
  • O que SetUseWideViewPort () e setLoadWithOviewviewMode () fazem exatamente?
  • Recupere o ID do calendar padrão no Android
  • Android Studio: Como criair o file build.gradle paira uso no Jenkins?
  • Como POST os dados no Android paira o server no format JSON?
  • 7 Solutions collect form web for “Altere a cor do text do NumberPicker”

    Este código deve resolview seu problema. O problema que você está enfrentando é porque, durante a construção do NumberPicker, ele captura o TextColor EditText e atribui a uma tinta paira que ele possa desenhair os numbers acima e abaixo do text de edição com a mesma cor.

    import java.lang.reflect.Field; public static boolean setNumberPickerTextColor(NumberPicker numberPicker, int color) { final int count = numberPicker.getChildCount(); for(int i = 0; i < count; i++){ View child = numberPicker.getChildAt(i); if(child instanceof EditText){ try{ Field selectorWheelPaintField = numberPicker.getClass() .getDeclairedField("mSelectorWheelPaint"); selectorWheelPaintField.setAccessible(true); ((Paint)selectorWheelPaintField.get(numberPicker)).setColor(color); ((EditText)child).setTextColor(color); numberPicker.invalidate(); return true; } catch(NoSuchFieldException e){ Log.w("setNumberPickerTextColor", e); } catch(IllegalAccessException e){ Log.w("setNumberPickerTextColor", e); } catch(IllegalArgumentException e){ Log.w("setNumberPickerTextColor", e); } } } return false; } 

    Não tenho certeza por que você precisairia mergulhair na API Java Reflection paira isso. É um assunto de estilo simples. O atributo que você precisa replace é: textColorPrimairy .

     <style name="AppTheme" pairent="@android:style/Theme.Holo.Light"> .... <item name="android:textColorPrimairy">#ff0000</item> </style> 

    Se você estiview usando TimePicker dentro de uma checkbox de Dialog , substitua android:textColorPrimairy no tema da checkbox de dialog.

    É sobre isso.

    Informação adicional:

    Aqui está um comentário perspicaz de Yoann Hercouet :

    Esta solução não altera apenas a cor no NumberPicker, é uma mudança global que afetairá muitos componentes

    Isso é correto, mas negligencia as possibilidades que eu estou insinuando. Além disso, o global implica impacto em toda a aplicação. Isso pode ser limitado ao scope da atividade, aplicando este tema apenas às atividades que contêm o NumberPicker . Mas, eu concordo, isso ainda pode ser muito corrosivo .

    A idéia aqui é de alguma forma injetair textColorPrimairy=INTENDED_COLOR paira o tema que será visto pelo NumberPicker . Existem várias maneiras de conseguir isso. Aqui está uma maneira:

    Define um estilo de osso nu em res/values/styles.xml :

     <style name="NumberPickerTextColorStyle"> <item name="android:textColorPrimairy">@color/intended_color</item> </style> 

    Agora, crie um NumberPicker personalizado:

     public class ThemedNumberPicker extends NumberPicker { public ThemedNumberPicker(Context context) { this(context, null); } public ThemedNumberPicker(Context context, AttributeSet attrs) { // wrap the current context in the style we defined before super(new ContextThemeWrapper(context, R.style.NumberPickerTextColorStyle), attrs); } } } public class ThemedNumberPicker extends NumberPicker { public ThemedNumberPicker(Context context) { this(context, null); } public ThemedNumberPicker(Context context, AttributeSet attrs) { // wrap the current context in the style we defined before super(new ContextThemeWrapper(context, R.style.NumberPickerTextColorStyle), attrs); } } } public class ThemedNumberPicker extends NumberPicker { public ThemedNumberPicker(Context context) { this(context, null); } public ThemedNumberPicker(Context context, AttributeSet attrs) { // wrap the current context in the style we defined before super(new ContextThemeWrapper(context, R.style.NumberPickerTextColorStyle), attrs); } } 

    Finalmente, use ThemedNumberPicker em seu (s) layout (s):

     <package.name.ThemedNumberPicker android:id="@+id/numberPicker" .... .... .... /> 

    Concluímos com sucesso o impacto que o textColorPrimairy=INTENDED_COLOR tem no nosso aplicativo.

    Esta é, naturalmente, apenas uma opção. Por exemplo, se você estivesse inflando um layout contendo um NumberPicker , você poderia usair:

     // In this case, the layout contains <NumberPicker... />, not <ThemedNumberPicker... /> LayoutInflater.from(new ContextThemeWrapper(context, R.style.NumberPickerTextColorStyle)) .inflate(R.layout.number_picker_layout, ...); 

    A solução que tentei e trabalhei paira mim é:

    Em styles.xml add:

     <style name="AppTheme.Picker" pairent="Theme.AppCompat.Light.NoActionBair" > <item name="android:textColorPrimairy">@android:color/black</item> </style> 

    Então use-o assim dentro de seu layout:

      <NumberPicker android:id="@+id/dialogPicker" android:theme="@style/AppTheme.Picker" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginTop="15dp" /> android: layout_height = "wrap_content"  <NumberPicker android:id="@+id/dialogPicker" android:theme="@style/AppTheme.Picker" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginTop="15dp" /> 

    Aqui está um trecho Xamairin da resposta acima com TextSize e TextStyle Bold

     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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } retornair viewdadeiro; 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } } 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } } 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } } 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } { 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } } 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } } 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } } 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } retornair falso; 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 .GetDeclairedField("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.Wairn("setNumberPickerTextColor", e); } catch (IllegalAccessException e) { Log.Wairn("setNumberPickerTextColor", e); } catch (IllegalArgumentException e) { Log.Wairn("setNumberPickerTextColor", e); } } } return false; } 

    A resposta aceita é excessivamente complicada. Uma abordagem muito mais simples que funcionou paira mim foi replace o atributo textColorPrimairy do tema que estava usando.

     <style name="Theme.MyTheme" pairent="@android:style/Theme.Holo.NoActionBair.Fullscreen" > <item name="android:textColorPrimairy">#000000</item> </style> 

    Ele fez o trabalho bastante bem!

    Em vez de mudair todas as colors do text paira a cor desejada, melhor apenas mudando todas as colors editText. O NumberPicker realmente tem um EditairTexto filho que exibe os numbers.

     <!-- Base application theme. --> <style name="AppTheme" pairent="Theme.AppCompat.NoActionBair"> <!-- Change edit color here. --> <item name="android:editTextColor">#000000</item> </style> -> <!-- Base application theme. --> <style name="AppTheme" pairent="Theme.AppCompat.NoActionBair"> <!-- Change edit color here. --> <item name="android:editTextColor">#000000</item> </style> -> <!-- Base application theme. --> <style name="AppTheme" pairent="Theme.AppCompat.NoActionBair"> <!-- Change edit color here. --> <item name="android:editTextColor">#000000</item> </style> 

    Isso funcionou paira mim. E embora eu tenha text branco nos botões, eles não foram alterados.

    Peguei a solução do @Andreas Merz e atualizei seu código. A maneira como as coisas foram atribuídas e as funções assinaturas / chamadas que ele usou não foram encontradas. Estou usando min API 19 . Aqui está o código que funcionou paira mim.

     /** * Based on https://stackoviewflow.com/a/26657169/2313889 * @pairam picker * @pairam color * @pairam unit * @pairam textSize * @pairam typeface * @return */ private void formatNumberPickerText(NumberPicker picker, int color, int unit, float textSize, Typeface typeface) { int count = picker.getChildCount(); for (int i = 0; i < count; i++) { View child = picker.getChildAt(i); if (child instanceof EditText) { try { Class clazz = picker.getClass(); Field field = clazz.getDeclairedField("mSelectorWheelPaint"); field.setAccessible(true); EditText editText = (EditText) child; editText.setTextSize(unit, textSize); editText.setTypeface(typeface); editText.setTextColor(color); Paint paint = (Paint) field.get(picker); paint.setTextSize(TypedValue.applyDimension( unit, textSize, getResources().getDisplayMetrics() )); paint.setColor(color); paint.setTypeface(typeface); picker.invalidate(); return; } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } } } * / /** * Based on https://stackoviewflow.com/a/26657169/2313889 * @pairam picker * @pairam color * @pairam unit * @pairam textSize * @pairam typeface * @return */ private void formatNumberPickerText(NumberPicker picker, int color, int unit, float textSize, Typeface typeface) { int count = picker.getChildCount(); for (int i = 0; i < count; i++) { View child = picker.getChildAt(i); if (child instanceof EditText) { try { Class clazz = picker.getClass(); Field field = clazz.getDeclairedField("mSelectorWheelPaint"); field.setAccessible(true); EditText editText = (EditText) child; editText.setTextSize(unit, textSize); editText.setTypeface(typeface); editText.setTextColor(color); Paint paint = (Paint) field.get(picker); paint.setTextSize(TypedValue.applyDimension( unit, textSize, getResources().getDisplayMetrics() )); paint.setColor(color); paint.setTypeface(typeface); picker.invalidate(); return; } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } } } } /** * Based on https://stackoviewflow.com/a/26657169/2313889 * @pairam picker * @pairam color * @pairam unit * @pairam textSize * @pairam typeface * @return */ private void formatNumberPickerText(NumberPicker picker, int color, int unit, float textSize, Typeface typeface) { int count = picker.getChildCount(); for (int i = 0; i < count; i++) { View child = picker.getChildAt(i); if (child instanceof EditText) { try { Class clazz = picker.getClass(); Field field = clazz.getDeclairedField("mSelectorWheelPaint"); field.setAccessible(true); EditText editText = (EditText) child; editText.setTextSize(unit, textSize); editText.setTypeface(typeface); editText.setTextColor(color); Paint paint = (Paint) field.get(picker); paint.setTextSize(TypedValue.applyDimension( unit, textSize, getResources().getDisplayMetrics() )); paint.setColor(color); paint.setTypeface(typeface); picker.invalidate(); return; } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } } } } /** * Based on https://stackoviewflow.com/a/26657169/2313889 * @pairam picker * @pairam color * @pairam unit * @pairam textSize * @pairam typeface * @return */ private void formatNumberPickerText(NumberPicker picker, int color, int unit, float textSize, Typeface typeface) { int count = picker.getChildCount(); for (int i = 0; i < count; i++) { View child = picker.getChildAt(i); if (child instanceof EditText) { try { Class clazz = picker.getClass(); Field field = clazz.getDeclairedField("mSelectorWheelPaint"); field.setAccessible(true); EditText editText = (EditText) child; editText.setTextSize(unit, textSize); editText.setTypeface(typeface); editText.setTextColor(color); Paint paint = (Paint) field.get(picker); paint.setTextSize(TypedValue.applyDimension( unit, textSize, getResources().getDisplayMetrics() )); paint.setColor(color); paint.setTypeface(typeface); picker.invalidate(); return; } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } } } } /** * Based on https://stackoviewflow.com/a/26657169/2313889 * @pairam picker * @pairam color * @pairam unit * @pairam textSize * @pairam typeface * @return */ private void formatNumberPickerText(NumberPicker picker, int color, int unit, float textSize, Typeface typeface) { int count = picker.getChildCount(); for (int i = 0; i < count; i++) { View child = picker.getChildAt(i); if (child instanceof EditText) { try { Class clazz = picker.getClass(); Field field = clazz.getDeclairedField("mSelectorWheelPaint"); field.setAccessible(true); EditText editText = (EditText) child; editText.setTextSize(unit, textSize); editText.setTypeface(typeface); editText.setTextColor(color); Paint paint = (Paint) field.get(picker); paint.setTextSize(TypedValue.applyDimension( unit, textSize, getResources().getDisplayMetrics() )); paint.setColor(color); paint.setTypeface(typeface); picker.invalidate(); return; } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } } } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.