Change "Month" text color in CalendarView

Varun Dwarkani :

I looked into multiple options of setting the textColor through various tags using a custom theme but none of them seem to work. I have attached screenshots for reference. Here's the custom theme I am using for when the theme of the app is Dark.

<style name="CalendarWeekDateTextDark" parent="TextAppearance.AppCompat.Button">
    <item name="android:textColor">@color/colorWhite</item>
</style>

and I have used it in the XML file as

<CalendarView
    android:id="@+id/calendarView"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:dateTextAppearance="?attr/CalendarWeekDatTextDark"
    android:weekDayTextAppearance="?attr/CalendarWeekDatTextDark"
    app:layout_constraintBottom_toTopOf="@+id/bottomGuideline"
    app:layout_constraintEnd_toEndOf="@+id/endGuideline"
    app:layout_constraintStart_toStartOf="@+id/startGuideline"
    app:layout_constraintTop_toBottomOf="@+id/topGuideline" />

Screenshots:

azizbekian :

Having defined following in styles.xml:

<style name="CustomCalendarMonth" parent="AppTheme">
    <item name="android:textColorPrimary">@color/orange</item>
</style>

<style name="CustomCalendarDay" parent="TextAppearance.MaterialComponents.Caption">
    <item name="android:textColor">@color/green</item>
</style>

<style name="CustomCalendarWeek" parent="TextAppearance.MaterialComponents.Caption">
    <item name="android:textColor">@color/purple</item>
</style>

Then in xml:

<CalendarView
    android:theme="@style/CustomCalendarMonth"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:dateTextAppearance="@style/CustomCalendarDay"
    android:weekDayTextAppearance="@style/CustomCalendarWeek" />

Here will be the output:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=319217&siteId=1