Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the text color of NumberPicker

I've looked at most all of the threads on this and none provided an answer that works. Styling the NumberPicker does not work (as per this thread: NumberPicker textColour)

Setting the style attribute on the numberPicker to a style that has a color item does not have any effect either. Nor does setting the textColor attribute on the numberPicker XML do anything.

Closest I've got to this is using the numberPicker to cast its getChildAt() to an EditText and then do setColor() on that EditText, but that only changes the color of the child once upon initialization and then every time it is selected from thereon; not what I am looking for either.

Any help? Thanks

like image 983
Odaym Avatar asked Apr 09 '14 12:04

Odaym


1 Answers

The solution I tried and worked for me is:

In styles.xml add:

<style name="AppTheme.Picker" parent="Theme.AppCompat.Light.NoActionBar" >     <item name="android:textColorPrimary">@android:color/black</item> </style> 

Then use it like this inside your layout:

  <NumberPicker     android:id="@+id/dialogPicker"     android:theme="@style/AppTheme.Picker"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_marginTop="15dp" /> 
like image 93
z3n105 Avatar answered Oct 05 '22 23:10

z3n105