-1

I want to set custom today to the MaterialDatePicker. But it getting the system date by default. Any idea?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841

1 Answers1

1

Too long for a comment. This answer doesn't solve your question but just explains why it is not possible to do it.

Currently (1.1.0-beta02 and 1.2.0-alpha02) you can't customize the value of the today.
In the adapter used by the MaterialDatePicker you can check:

if (UtcDates.getTodayCalendar().getTimeInMillis() == date) {
    calendarStyle.todayDay.styleItem(day);
    //..
  } else {
    calendarStyle.day.styleItem(day);
    //..
  }

You can customize the style used by the Day.Today.

 <style name="CustomThemeOverlay.MaterialComponents.MaterialCalendar"
       parent="ThemeOverlay.MaterialComponents.MaterialCalendar" >
   <item name="materialCalendarStyle">@style/CustomWidget_MaterialCalendar</item>
 </style>

 <style name="CustomWidget_MaterialCalendar" parent="Widget.MaterialComponents.MaterialCalendar">
    <item name="dayTodayStyle">@style/CustomWidget_DayToday</item>
  </style>

  <style name="CustomWidget_DayToday" parent="Widget.MaterialComponents.MaterialCalendar.Day.Today">
     <item name="itemTextColor">@color/...</item>
     <item name="itemStrokeColor">@color/...</item>
  </style>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841