How can I add icons to Calendar component in android? I want to show free days using userfriendy graphics

Viewed 129

Nowadays I get JSON data {day1, day2, day3...}. How can I add images/icons to this.. ?

    CalendarView calendarView = new CalendarView(this);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(90, 40, 80, 40);
    calendarView.setLayoutParams(layoutParams);
1 Answers

I'd say it's not possible with this specific component since there's no public method to add image. You can check the CalendarView documentantion.

I'd recommend to you two ways : Either you create your own GridLayout or your CalendarCustomView so you specify your layout and in each cell (that would be the day) you add a space for an ImageView and use it.

Or use a library that does what you want.

Just chose the one that fits better with your needs.

An example of library could be : Nevalla CalendarView Applandeo Material Calendar View Etc...

Related