Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change date-picker text color in spinner mode in android?

I have tried using custom style but it is not working , its default color is greyish and I want it to be white colored, can anyone help me out? TIA

XML

<DatePicker
    android:id="@+id/user_dob"
    android:hapticFeedbackEnabled="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:calendarViewShown="false"
    style="@style/MyDatePickerStyle"
    android:datePickerMode="spinner"/>

styles   
<style name="MyDatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker" tools:targetApi="lollipop">
    <item name="android:headerBackground">@color/white</item>
    <item name="android:calendarTextColor">@color/white</item>
    <item name="android:dayOfWeekBackground">@color/white</item>
    <item name="android:yearListSelectorColor">@color/white</item>
    <item name="android:datePickerMode">calendar</item>
    <item name="android:minDate">01/01/1970</item>
</style>
like image 784
Chirag Gupta Avatar asked Jun 25 '20 18:06

Chirag Gupta


1 Answers

You can use:

<DatePicker
   android:theme="@style/MyDatePicker"
   ..>

with:

<style name="MyDatePicker" >
    <!-- Text color -->
    <item name="android:textColorPrimary">@color/....</item>
    <!-- Divider color -->
    <item name="colorControlNormal">@color/...</item>
</style>

enter image description here

like image 71
Gabriele Mariotti Avatar answered Nov 01 '22 17:11

Gabriele Mariotti