Open CarotUnima opened 5 years ago
I had that issue too and it is solve thanks to DayViewDecorator
public class EventDecorator implements DayViewDecorator {
private final ArrayList<CalendarDay> dates;
private final Context context;
public EventDecorator(Context context, ArrayList<CalendarDay> dates) {
this.dates = dates;
this.context = context;
}
@Override
public boolean shouldDecorate(CalendarDay day) {
return dates.contains(day);
}
@Override
public void decorate(DayViewFacade view) {
Drawable drawable = ContextCompat.getDrawable(context,R.drawable.calcircleselector);
assert drawable != null;
view.setBackgroundDrawable(drawable);
}
}
Just set "calcircleselector" drawable with the desired colors & shape
You can set multiple dayViewDecorators to the calendar, each one will represent a set of dates with a custom color
EventDecorator eventDecorator = new EventDecorator(getContext(), calDaysArr);
binding.calendarView.addDecorator(eventDecorator);
I had that issue too and it is solve thanks to DayViewDecorator
public class EventDecorator implements DayViewDecorator { private final ArrayList<CalendarDay> dates; private final Context context; public EventDecorator(Context context, ArrayList<CalendarDay> dates) { this.dates = dates; this.context = context; } @Override public boolean shouldDecorate(CalendarDay day) { return dates.contains(day); } @Override public void decorate(DayViewFacade view) { Drawable drawable = ContextCompat.getDrawable(context,R.drawable.calcircleselector); assert drawable != null; view.setBackgroundDrawable(drawable); } }
Just set "calcircleselector" drawable with the desired colors & shape
You can set multiple dayViewDecorators to the calendar, each one will represent a set of dates with a custom color
EventDecorator eventDecorator = new EventDecorator(getContext(), calDaysArr); binding.calendarView.addDecorator(eventDecorator);
You can show me "calcircleselector.xml" . please
I had that issue too and it is solve thanks to DayViewDecorator
public class EventDecorator implements DayViewDecorator { private final ArrayList<CalendarDay> dates; private final Context context; public EventDecorator(Context context, ArrayList<CalendarDay> dates) { this.dates = dates; this.context = context; } @Override public boolean shouldDecorate(CalendarDay day) { return dates.contains(day); } @Override public void decorate(DayViewFacade view) { Drawable drawable = ContextCompat.getDrawable(context,R.drawable.calcircleselector); assert drawable != null; view.setBackgroundDrawable(drawable); } }
Just set "calcircleselector" drawable with the desired colors & shape You can set multiple dayViewDecorators to the calendar, each one will represent a set of dates with a custom color
EventDecorator eventDecorator = new EventDecorator(getContext(), calDaysArr); binding.calendarView.addDecorator(eventDecorator);
You can show me "calcircleselector.xml" . please
Sure, it is just a simple oval shape, and certainly customise it according to your needs
and the dot color can be edited within the decorate function too
view.addSpan(new DotSpan(Color.BLUE));
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/color_blue"/>
</shape>
how to set the default appointment color blue and when i select the date the blue will be changed into white.
I want change color DotSpan when I selected day
I want look like:
But ...