Jordan Carlyon
Jordan Carlyon

Reputation: 53

Material Date Picker text color

I am trying to change the text color of my DatePicker

 <DatePicker
            android:id="@+id/start_date_text"
            android:layout_width="400dp"
            android:layout_height="190dp"
            android:datePickerMode="spinner"
            android:calendarViewShown="false"
            style="@style/MyDatePicker" />

This code just gives 3 pickers, month, day and year. How can I change this text color?

 <style name="MyDatePicker" parent="android:Widget.Material.Light.DatePicker">
    <item name="android:textColor">@color/Black</item>
</style>

where Widget.Material.Light.DatePicker has been all the DatePicker options under Widget

Upvotes: 5

Views: 16596

Answers (3)

Joe Pleavin
Joe Pleavin

Reputation: 536

An updated version would be to use editTextColor instead of using textColorPrimary and time pickers as suggested by tachyonflux date.

try:

<style name="NumberPickerStyle" >
    <item name="android:editTextColor">@android:color/black</item>
</style>

Upvotes: 1

tachyonflux
tachyonflux

Reputation: 20211

As with most components, the DatePicker's text color is effected by textColorPrimary:

<item name="android:textColorPrimary">@color/Black</item>

Upvotes: 22

Jorge Casariego
Jorge Casariego

Reputation: 22212

I don't know what your style have but you can do it this way:

<style name="MyDatePicker" parent="@android:style/Widget.DeviceDefault.DatePicker">

  <item name="android:textColor">#FF0000</item>

</style>

Upvotes: -1

Related Questions