Centre date number in cell in Android

5 posts, 0 answers
  1. Ian
    Ian avatar
    68 posts
    Member since:
    Jul 2017

    Posted 31 Jul 2018 Link to this post

    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?
  2. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1195 posts

    Posted 01 Aug 2018 Link to this post

    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
  3. Ian
    Ian avatar
    68 posts
    Member since:
    Jul 2017

    Posted 01 Aug 2018 in reply to Lance | Manager Technical Support Link to this post

    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.

  4. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1195 posts

    Posted 01 Aug 2018 Link to this post

    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
  5. Ian
    Ian avatar
    68 posts
    Member since:
    Jul 2017

    Posted 01 Aug 2018 in reply to Lance | Manager Technical Support Link to this post

    Oh yes, that works. Thanks.
Back to Top