Closed RakeshPatil111 closed 3 years ago
Found solution
Whats the solution ?
What was the solution, @RakeshPatil111 ?
What is the solution?
Add custom decorator.
class CalendarDateTodayDecorator(val context: Context) : DayViewDecorator {
override fun shouldDecorate(day: CalendarDay?): Boolean {
return day == CalendarDay.today()
}
override fun isDecorationDynamic(): Boolean {
return true
}
override fun decorate(view: DayViewFacade?) {
view?.addSpan(ForegroundColorSpan(ContextCompat.getColor(context, R.color.red)))
}
}
Set this decorator,
view.addDecorators(CircularDateSelectionDecorator(requireContext()), calendarDateDecorator)
I needed circle around selected date so created CircularDateSelectionDecorator, you can create other decorators depending upon your need.
class CircularDateSelectionDecorator(context: Context) : DayViewDecorator {
private val drawable: Drawable = ContextCompat.getDrawable(context, R.drawable.event_calendar_date_selector)!!
override fun shouldDecorate(day: CalendarDay): Boolean {
return true
}
override fun isDecorationDynamic(): Boolean {
return false
}
override fun decorate(view: DayViewFacade) {
view.setSelectionDrawable(drawable)
}
NOTE This solution is a 2 years old, may be will not work now.
Add custom decorator.
class CalendarDateTodayDecorator(val context: Context) : DayViewDecorator { override fun shouldDecorate(day: CalendarDay?): Boolean { return day == CalendarDay.today() } override fun isDecorationDynamic(): Boolean { return true } override fun decorate(view: DayViewFacade?) { view?.addSpan(ForegroundColorSpan(ContextCompat.getColor(context, R.color.red))) } }
Set this decorator,
view.addDecorators(CircularDateSelectionDecorator(requireContext()), calendarDateDecorator)
I needed circle around selected date so created CircularDateSelectionDecorator, you can create other decorators depending upon your need.
class CircularDateSelectionDecorator(context: Context) : DayViewDecorator { private val drawable: Drawable = ContextCompat.getDrawable(context, R.drawable.event_calendar_date_selector)!! override fun shouldDecorate(day: CalendarDay): Boolean { return true } override fun isDecorationDynamic(): Boolean { return false } override fun decorate(view: DayViewFacade) { view.setSelectionDrawable(drawable) }
NOTE This solution is a 2 years old, may be will not work now.
Thank you
How to set text color for today's date and different text color for selected date?