Hello Rincy,
Thank you for contacting the Android team.
I made a simple implementation of the screenshot you provided. Here is the code to get you started:
private
RadCalendarView calendarView;
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this
.calendarView =
new
RadCalendarView(
this
);
this
.calendarView.setAdapter(
new
CustomCalendarAdapter(
this
.calendarView));
this
.calendarView.getEventAdapter().setRenderer(
new
CustomEventRenderer(
this
));
List<Event> events =
new
ArrayList<>();
events.add(
new
Event(
"Event"
, Calendar.getInstance().getTimeInMillis(), Calendar.getInstance().getTimeInMillis() + 1));
this
.calendarView.getEventAdapter().setEvents(events);
this
.calendarView.getAdapter().setStyle(CalendarStyles.light(
this
));
setContentView(
this
.calendarView);
}
private
static
class
CustomCalendarAdapter extends CalendarAdapter {
public
CustomCalendarAdapter(RadCalendarView owner) {
super(owner);
}
@Override
protected
CalendarDayCell generateCalendarDayCell() {
return
new
CustomCalendarDayCell(
this
.owner);
}
}
private
static
class
CustomCalendarDayCell extends CalendarDayCell {
public
CustomCalendarDayCell(RadCalendarView owner) {
super(owner);
}
@Override
protected
void
drawEvents(Canvas canvas) {
if
(
this
.getEvents() !=
null
&&
this
.getEvents().size() > 0)
this
.owner.getEventAdapter().getRenderer().renderEvents(canvas,
this
);
}
}
private
static
class
CustomEventRenderer extends EventRenderer {
private
static
final
int
COLOR_IDLE = Color.parseColor(
"#38b4db"
);
private
static
final
int
COLOR_SELECTED = Color.parseColor(
"#ffffff"
);
private
float
size;
private
Paint paint;
public
CustomEventRenderer(Context context) {
super(context);
this
.size = Util.getDimen(TypedValue.COMPLEX_UNIT_DIP, 20);
this
.paint =
new
Paint(Paint.ANTI_ALIAS_FLAG);
}
@Override
public
void
renderEvents(Canvas canvas, CalendarDayCell cell) {
Path path =
new
Path();
path.moveTo(cell.getRight() -
this
.size, cell.getBottom());
path.lineTo(cell.getRight(), cell.getBottom());
path.lineTo(cell.getRight(), cell.getBottom() -
this
.size);
path.close();
if
(cell.isSelected())
this
.paint.setColor(COLOR_SELECTED);
else
this
.paint.setColor(COLOR_IDLE);
canvas.drawPath(path,
this
.paint);
}
}
This should be close to the desired result. Please let me know if you need some further assistance.
Thank you for your time and all best!
Regards,
Antony Jekov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.