Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Calendar View change text color

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.

like image 716
Okke Trommelen Avatar asked May 18 '16 13:05

Okke Trommelen


People also ask

How to change color in google calendar android?

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.

How to set a date on calendar view in android?

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.


1 Answers

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>
like image 84
Md Imran Choudhury Avatar answered Sep 20 '22 22:09

Md Imran Choudhury