Nokas,
To set events you can use the following code:
calendarView.addEvent(new Event(date, "Feriado X"));
To highlight events, you’ll need to use decorators on specific dates, where you define how this personalization should be according to the date type.
In the documentation there is an example of how to place a point on specific dates:
public class EventDecorator implements DayViewDecorator {
private final int color;
private final HashSet<CalendarDay> dates;
public EventDecorator(int color, Collection<CalendarDay> dates) {
this.color = color;
this.dates = new HashSet<>(dates);
}
@Override
public boolean shouldDecorate(CalendarDay day) {
return dates.contains(day);
}
@Override
public void decorate(DayViewFacade view) {
view.addSpan(new DotSpan(5, color));
}
}
Calling the Decorator:
calendarView.addDecorators(new EventDecorator(this));
You can also set more than one developer for different cases:
public class FeriadoDecorator implements DayViewDecorator{
@Override
public void decorate(DayView view,Context context) {
view.setBackground(generateCircleDrawable(color));
}
}
Adding Custom Designer:
widget.addDayViewDecorator(new FeriadoDecorator (), dates);
https://github.com/prolificinteractive/material-calendarview/blob/master/docs/DECORATORS.md
You can use custom styles for the first day of the month, for example:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:state_checked="true" android:drawable="@drawable/selected_bg_color" />
<item android:state_pressed="true" android:drawable="@drawable/selected_bg_color" />
<item android:drawable="@drawable/red_circle" />
red_circle:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<stroke android:width="2dp" android:color="@color/selected_color" />
selected_bg_color:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<solid android:color="@color/selected_color"/>
<size android:width="120dp" android:height="120dp"/>
Source: https://stackoverflow.com/a/37881374/5626568
Thank you so much! I will test
– Nokas
I already tested it! I managed to put a colored "stitch" on a certain date, but instead of putting this stitch I put a small string and it didn’t work...
– Nokas
Collection<CalendarDay> colldates;
 colldates = new HashSet<>();
 CalendarDay eventDay2 = CalendarDay.from(2017, 07, 18);
 colldates.add(eventDay2);
 materialCalendarView.addDecorator(new EventDecorator(colldates, "Nokas")); **I changed the Eventdecorator Class or the Decorate ** view.addSpan(new String(n)); What am I doing wrong? Sync and corrections by n17t01
– Nokas
@Nokas edited the answer, put an example at the end...
– ℛɑƒæĿᴿᴹᴿ
Thank you but tested and still does not give @ℛɑ?æ is not accepting the new Textspan, does not recognize.
– Nokas