Android CalendarView to show events

I want to show a calendar with events using different colors on a date similar to setting the default calendar. But I do not see such an API in the default calendar view.

Can someone direct me in the right direction how to do this? Should I extend the default calendar and add my own features? Or should I use 5x5 text fields with PageViewer and snippets?

+23
source share
5 answers

The built-in CalendarView widget does not provide the ability to change the color of the calendar cells in the month view mode. See source .

You can try the following approaches:

  • Extend with CalendarView and implement onDraw yourself. You will have to override all existing drawing behavior, including these 4 methods:

      protected void onDraw (Canvas canvas) {
         drawBackground (canvas);
         drawWeekNumbersAndDates (canvas);
         drawWeekSeparators (canvas);
         drawSelectedDateVerticalBars (canvas);
     }
    
  • Implement your own CalendarView, which allows you to customize cells. I propose this project as a good place to get started, as it already supports custom cells.

+19
source

Last month, I was able to implement a small calendar view using Caldroid https://github.com/roomorama/Caldroid .

This is a flexible way to use, and it’s not as difficult to get a custom calendar view as the onDraw implementation from CalendarView .

Check the created view (just following the documentation):

Custom calendar view using Caldroid

And, of course, you can go further.

+10
source

I wrote my own CalendarView just like the one that was seen on Google calendars. It allows you to scroll between months, listeners, add events, and is a gradle project: https://github.com/SundeepK/CompactCalendarView . It uses paint to complete the entire drawing, so it's easy to change it to do whatever you want.

+5
source

The following project is the best alternative I've seen so far to allow the display of visual events associated with a specific event in a date cell in the calendar:

https://github.com/tyczj/ExtendedCalendarView

+4
source

How about changing the color of certain dates - using android: dateTextAppearance and setDateTextAppearance (int)? It was once described: change the color of calendar dates android you can try this

0
source

Source: https://habr.com/ru/post/957242/


All Articles