androidxmlkotlinmaterialdatepicker

Is it possible to change the font size of the header in the Material Datepicker component on Android?


My team wants me to change the font size of the Material Datepicker title to be more visible for accessibility reasons on Android. Is it possible and how?

enter image description here


Solution

  • Yes you can change the size of Title.

    Material Date Picker uses this theme

     <style name="MaterialCalendarTheme" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
        <!-- just override the colors used in the default style -->
        <item name="colorOnPrimary">@color/white</item>
        <item name="colorPrimary">@color/spruce_valencia</item>
        <item name="materialCalendarHeaderTitle">@style/date_text_appearance</item>
    
    </style>
    
    <style name="date_text_appearance" parent="@style/TextAppearance.AppCompat">
        <item name="android:textSize">@dimen/text_xlarge_heading</item>
    </style>
    

    materialCalendarHeaderTitle is what does the trick and rest you can change the use textSize attribute to change the Text Size.

    Here is how it looks

    More about Material Date Picker attributes and layouts you can trace back this google material repo.

    Here is the link to all the styles which are used in the Material Date Picker just find the relevant style applied in layouts and customise. Enjoy.