Scroll RadCalendar inside a ScrollView
Environment
Product Version | 2019.2 708.1 |
Product | Calendar for Xamarin |
Description
A scenario where the RadCalendar is used within a ScrollView is not that common and such gesture conflicts might be observed as we have different native implementations of the RadCalendar for the different platforms. This help article will show you how to scroll right/left the calendar on Android when the control is positioned inside a ScrollView.
Solution
The calendar in Android supports horizontal scrolling. In order to apply this you will need to create a custom renderer for Android. More information about custom renderers for RadCalendar control you can find in our help topic: Custom Calendar Renderer.
Here are the steps you need to follow in order to create a custom renderer:
You will need to create a class inside the Android project which inherits from Telerik.XamarinForms.InputRenderer.Android.CalendarRenderer and override the OnElementChanged method. Inside it set HorizontalScroll to the calendar control.
Then register your custom renderer using the ExportRenderer assembly level attribute.
For example:
[assembly: ExportRenderer(typeof(RadCalendar), typeof(CustomCalendarRenderer))]
namespace CalendarExample.Droid
{
public class CustomCalendarRenderer : CalendarRenderer
{
public CustomCalendarRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<RadCalendar> e)
{
base.OnElementChanged(e);
this.Control.HorizontalScroll = true;
}
}
}