This is a migrated thread and some comments may be shown as answers.

Can I apply background image instead of background color for Calendar cell?

3 Answers 132 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
vijay
Top achievements
Rank 1
vijay asked on 09 Jun 2015, 06:26 AM

I want to apply background image because I have one scenario like on 2nd June employee half day on on-duty(outside for office work) and half day in office or absent.

CASE:1

I want to add background color for this scenario half cell is Green and half cell is Blue is this possible ?

CASE:2

I want to add background image for this scenario is this possible?

Please let me know the correct solution.

Thanks

 

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 12 Jun 2015, 06:51 AM
Hi Vijay,

Thanks for writing.

You can add an image to the CalendarCell as part of the CustomizationRule mechanism. We are using it one of our examples that are available in the store, here is the full code, and here's just an excerpt with the customization part which does that:

this.calendarView.setCustomizationRule(new Procedure<CalendarCell>() {
    @Override
    public void apply(CalendarCell argument) {
        if (argument.getCellType() == CalendarCellType.Date) {
            calendar.setTimeInMillis(argument.getDate());
            if (calendar.get(Calendar.DAY_OF_MONTH) == 6 || calendar.get(Calendar.DAY_OF_MONTH) == 7) {
                argument.setBackgroundColor(Color.parseColor("#f9cc9d"), Color.parseColor("#f9cc9d"));
                argument.setBorderColor(borderColor);
                argument.setBorderWidth(borderWidth);
                argument.setBitmap(sun);
            } else {
                argument.setBackgroundColor(colorEnabled, colorDisabled);
                argument.setBorderColor(Color.TRANSPARENT);
                argument.setBitmap(null);
            }
        }
    }
});

This changes the background color, the border color, the border width and adds an image for dates that are 6th or 7th. You can use this approach to add image to dates of your choice. The half-coloring of dates is not supported, but you may be able to achieve a similar result by setting for example Green background for the cell and adding a simple Blue image.

I hope this information helps.

Regards,
Todor
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jaune
Top achievements
Rank 1
answered on 26 Feb 2016, 02:36 PM

Hi,

I am using Xamarin for Android. How can I implement setBitmap for a CalendarCell in C#?

 

0
Todor
Telerik team
answered on 02 Mar 2016, 08:39 AM
Hello Jaune,

Yes, in Xamarin for Android the approach is quite similar. Here's the article which contains a C# snippet for the customization rule. The difference is that in java the bitmap is set through the setBitmap method, while in C# it is done through the Bitmap property:

argument.Bitmap = sun;

I hope this information helps.

Regards,
Todor
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Calendar
Asked by
vijay
Top achievements
Rank 1
Answers by
Todor
Telerik team
Jaune
Top achievements
Rank 1
Share this question
or