Android CalendarView for Showing Events
Solution 1
The built in CalendarView widget doesn't expose the ability to change the color of the calendar cells in month view. See the source.
You might try the following approaches:
-
Extend from CalendarView and implement onDraw yourself. You'll have to reimplement all the existing drawing behavior, including these 4 methods:
protected void onDraw(Canvas canvas) { drawBackground(canvas); drawWeekNumbersAndDates(canvas); drawWeekSeparators(canvas); drawSelectedDateVerticalBars(canvas); }
Implement you own CalendarView that allows customizing cells. I suggest this project as a good place to get started, since it already supports custom cells.
Solution 2
Last month I was able to implement a little calendar view using Caldroid https://github.com/roomorama/Caldroid.
It's flexible to use and it's not so hard to get a custom calendar view as implementing onDraw
from the CalendarView
.
Check the view I created (just by following the documentation):
And of course you can go beyond that.
Solution 3
I've written my own CalendarView much like the one seen in Google calendars aswell. Gives the ability to scroll between months, listeners, add events and is a gradle project: https://github.com/SundeepK/CompactCalendarView. It uses paint to do all the drawing so it should easy to change to do anything you want.
Solution 4
The following project is the best alternative I have seen so far to allow for displaying event-specific visuals in a date cell on the calendar:
![Karthik Andhamil](https://i.stack.imgur.com/b2SWj.jpg?s=256&g=1)
Karthik Andhamil
Independent Android App Developer Andhamil Better Apps for Better People Check out our apps on Google Play and Amazon Appstore Connect with us on Facebook, Google+ and Twitter
Updated on October 09, 2020Comments
-
Karthik Andhamil over 3 years
I want to show a calendar with events using different colors on the date similar to default Calendar application. But I don't see any such API on the default calendar view.
Can anyone please direct me on right direction how to proceed with this? Should I extend default calendar and add my own functionality? Or should I use 5x5 text boxes with PageViewer and fragments?