androidmaterial-designmaterial-components-androidandroid-datepickermaterialdatepicker

How to change the Material Date & Time Picker background color in Android?


How to change the Material Date & Time Picker background color in Android? i found many solution default date & time picker not Material design


Solution

  • You can override the default color using:

        val datePicker =
            MaterialDatePicker.Builder.datePicker()
                .setTheme(R.style.ThemeOverlay_App_MaterialCalendar)
                .build() 
    

    with:

     <style name="ThemeOverlay.App.MaterialCalendar" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
        <!-- just override the colors used in the default style -->
        <item name="colorOnPrimary">@color/...</item>
        <item name="colorPrimary">@color/...</item>
      </style>
    

    enter image description here

    or if you want to change also the white background:

       <style name="ThemeOverlay.App.MaterialCalendar4" parent="@style/ThemeOverlay.MaterialComponents.MaterialCalendar">
            <item name="colorSurface">@color/...</item>
        </style>
    

    enter image description here