Android Calendar View change text color
Solution 1
Set style in your CalendarView
<CalendarView
android:id="@+id/calendarView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:theme="@style/CalenderViewCustom"
android:dateTextAppearance="@style/CalenderViewDateCustomText"
android:weekDayTextAppearance="@style/CalenderViewWeekCustomText" />
Inside Style.xml
<style name="CalenderViewCustom" parent="Theme.AppCompat">
<item name="colorAccent">@color/red</item>
<item name="colorPrimary">@color/white</item>
</style>
<style name="CalenderViewDateCustomText" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textColor">@color/white</item>
<item name="android:weekNumberColor">@color/red</item>
</style>
<style name="CalenderViewWeekCustomText" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textColor">@color/white</item>
</style>
Solution 2
android:theme="@style/testTheme"
Use this theme or a custom theme which has parent as this theme.
To make it white
To Choose other than white change the color use the following
android:textColorPrimary="@color/yourColor"
or other text colors use the following
android:weekDayTextAppearance="@style/weekDayTextAppearance"
android:dateTextAppearance="@style/appTextAppearance"
android:unfocusedMonthDateColor="@color/colorLoginBtn"
android:selectedWeekBackgroundColor="@color/colorLoginBtn"
android:weekSeparatorLineColor="@color/colorLoginBtn"
android:focusedMonthDateColor="@color/colorLoginBtn"
android:weekNumberColor="@color/colorLoginBtn"
Okke Trommelen
Updated on December 08, 2020Comments
-
Okke Trommelen over 3 years
I have a
CalendarView
in my app. But I would like to have the background of theCalendarView
black and the text inside theCalendarView
white. But in xml there is noTextColor=
in theCalendarView
. So how can I change the text of theCalendarView
?I have tried every solution on StackOverflow and the internet so far. I've managed to change the color of the days in the CalendarView but not the month and year.
I've tried both methods in this post: Set the text color of calendar view month name
And I've tried this method: Change CalendarView style
And some other I found on the internet but nothing was succesfull.
-
AnupamChugh almost 6 yearsColor of calendar view month name is white here.