I have a CalendarView
in my app. But I would like to have the background of the CalendarView
black and the text inside the CalendarView
white. But in xml there is no TextColor=
in the CalendarView
. So how can I change the text of the CalendarView
?
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.
Log in to your Google account and navigate to Google Calendar. In the list of calendars on the left side of the screen, hover your cursor over the desired calendar > Click the "Options" icon (3 stacked dots). From the resulting menu, choose the desired color from the color palette. the calendar color is changed.
To set the current date we do setDate(long date) on the CalendarView instance. The setDate method has another form: setDate(long date, boolean animate, boolean center) . By default the second and third parameters are true. When you select a new date it animates to it.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With