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

Centre date number in cell in Android

4 Answers 39 Views
Calendar & Scheduling
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 01 Aug 2018, 01:12 AM
Is it possible to have the Android version of the calendar draw the number of the date in the centre of the day cell, as it is on iOS, instead of in the top right?

4 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 01 Aug 2018, 09:56 AM
Hello Ian,

You can style most of the element properties within XamarinForms (see Styling).

However, to change layout, you'll need to use a custom renderer and access the native Android CalendarView.

The Android Custom Renderer and Android CalendarView Customizations article (see "SetTextPosition" method, this would be TextPosition in C#) will help you set that up.

If you have any trouble implementing it, reply back with your custom renderer class and I'll investigate directly.

Regards,
Lance | Tech Support Engineer, Sr.
Progress 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
Ian
Top achievements
Rank 1
answered on 01 Aug 2018, 02:51 PM

Hi Lance,

I got this working...

protected override void OnElementChanged(ElementChangedEventArgs<RadCalendar> e)
{
    base.OnElementChanged(e);
 
    var filter = new CalendarDayCellFilter
    {
        CellType = Com.Telerik.Widget.Calendar.CalendarCellType.Date
    };
 
    var style = new CalendarDayCellStyle
    {
        Filter = filter
        TextPosition = new Java.Lang.Integer(4 | 8)
    };
 
    Control.AddDayCellStyle(style);
}

 

But how does one access CalendarElement.AlignRight given that it's not a static? At present, I'm using raw integers.

0
Lance | Manager Technical Support
Telerik team
answered on 01 Aug 2018, 03:13 PM
Hello Ian,

You should be able to use explicit conversion, try the following:

using Com.Telerik.Widget.Calendar;
...
 
var style = new CalendarDayCellStyle
{
    Filter = filter,
    TextPosition = (Java.Lang.Integer)(CalendarElement.CenterHorizontal | CalendarElement.CenterVertical)
};

Regards,
Lance | Tech Support Engineer, Sr.
Progress 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
Ian
Top achievements
Rank 1
answered on 01 Aug 2018, 03:17 PM
Oh yes, that works. Thanks.
Tags
Calendar & Scheduling
Asked by
Ian
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Ian
Top achievements
Rank 1
Share this question
or