Changing the color of selected dates in android's CalendarView widget
Asked Answered
P

2

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.

Purine answered 19/7, 2014 at 8:33 Comment(0)
C
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

Cashman answered 23/11, 2014 at 6:10 Comment(0)
O
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

Opportuna answered 7/2, 2023 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.