android-layoutandroid-stylescalendarview

How to change today's date color android CanlendarView


I have created some custom styles for CalendarView to change the text colors:

    <style name="CalenderViewCustom" parent="Theme.AppCompat">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorAccent">@color/colorAccentYellow</item>
        <item name="android:textColorPrimary">@color/colorPrimaryDarker</item>
    </style>

And applied them into the calendar like so:

<CalendarView
     ...
     android:theme="@style/CalenderViewCustom"
     android:dateTextAppearance="@style/CalenderViewDateCustomText"
     android:weekDayTextAppearance="@style/CalenderViewWeekCustomText"
     ...
/>

I would like to change the text color of '9', to a different one from the background of '16'.
Currently, both of them are determined by the colorAccent attribute.

enter image description here

Is there any other attribute that would change only one of them separately?


Solution

  • Found a pretty cool solution:
    We can use the CompactCalendarView package which is a little old but still works perfectly fine (Android 26+)

    For example to set the "today" color to black:

           <com.github.sundeepk.compactcalendarview.CompactCalendarView
                android:layout_width="match_parent"
                android:layout_height="280dp"
                ...
                app:compactCalendarCurrentDayTextColor="@android:color/black"
                ...
                />