I would like to highlight specific dates in a calendar view as in this image. is it possible to achieve it in with the default CalenderView
provided by the android framework. I searched and found some libraries but I am looking for simple solution, also I dont want to creat my own calenderView. I also found that I can extend the CalenderView
and add functionality to it. if so what method or parameter should I override in the extended class and how to do that.
Asked
Active
Viewed 1,149 times
3
-
please check this https://stackoverflow.com/questions/41237073/how-do-i-change-the-background-color-of-calendar-dates-in-materialcalendarview – Nour Eldien Mohamed Jul 16 '20 at 07:32
-
I am not using any Libraries – Dharmaraj Jul 16 '20 at 09:54
1 Answers
0
you just take custom Calender-View you just find here
And then add this extra Method in Legacy CalendarViewDelegate class similar to the setFocusedMonthDateColor() method to iterate through the weeks and set a date and color in the WeekView class
public void setMonthDateColor(Date date, int color) {
final int childCount = mListView.getChildCount();
for (int i = 0; i < childCount; i++) {
WeekView weekView = (WeekView) mListView.getChildAt(i);
if (weekView.isDateInWeek(date)) {
//this method adds the date and colour to a
//Map collection in weekView Object
weekView.setDateColour(date, color);
}
}
}
The above method then needs to be exposed by adding another method to the parent class CalendarViewCustom (similar to its existing methods) which can then be called on an instance of the class
public int setMonthDateColor(Date date, int color) {
return mDelegate.getMonthDateColor(date, color);
}

Sarthak Dhami
- 330
- 1
- 5
- 14
-
I don't find the `LegacyCalendarViewDelegate` class inside `CalendarView` source code. also, can you elaborate your answer as I am a beginner – Dharmaraj Jul 16 '20 at 09:50