18

How do i change the color of the selected day in the CalendarView widget provided by android. I don't seem to find any way in the documentation.

I can change the VerticalBars using setSelectedDateVerticalBar attribute but I want to set a background color like the one shown in this pic. enter image description here

I want to set the color and appearance like the one on the left but all I can get is the one on the right. Is the CalendarView library so poorly built?

Any help is greatly appreciated.

Vinay Potluri
  • 545
  • 1
  • 9
  • 23

2 Answers2

4

There is no way to do what you are trying to achieve currently. The Calendar View is very limited in its functionality.

See this: Change CalendarView style

Community
  • 1
  • 1
Kevin Michael
  • 118
  • 1
  • 7
0

You can change your selected date color with create a selector.

create a selector file: your_selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_activated="true" android:color="@color/white" />
    <item android:color="@color/color_black" />
</selector>

Use your selector in style :

<style name="CalenderViewDateCustomText">
        <item name="colorControlNormal">@color/white</item>
        <item name="colorControlActivated">@color/white</item>
        <item name="colorControlHighlight">@color/white</item>
        <item name="android:textColor">@drawable/your_selector</item>
    </style>

use it in calender view :

<CalendarView
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:theme="@style/CalenderViewCustom"
 android:dateTextAppearance="@style/CalenderViewDateCustomText"                        
 android:weekDayTextAppearance="@style/CalenderViewWeekCustomText"
 app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintStart_toStartOf="parent"
 app:layout_constraintTop_toTopOf="parent" />

calendar example