Change text color of weeknumbers

5 posts, 1 answers
  1. Maurits
    Maurits avatar
    7 posts
    Member since:
    May 2016

    Posted 04 Jul Link to this post

    How do I change the color of the week numbers (either in Block or in Inline mode)?

    I tried assigning a color to the "CalendarAdapter.WeeknumberCell.TextColor" property but this doesn't seem to work. Below is the code I am using now (the day names and title do change color):

    var calendarView = (RadCalendarView)FindViewById(Resource.Id.calendarView);
    var textColor = ContextCompat.GetColor(this.BaseContext, Resource.Color.uurwerk_purple);
     
    var calendarAdapter = calendarView.Adapter;
    calendarAdapter.DayNameTextColor = textColor;
    calendarAdapter.TitleTextColor = textColor;
    calendarAdapter.WeekNumberCell.TextColor = textColor;

  2. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 05 Jul Link to this post

    Hi Maurits,

    Thanks for writing.

    Here's a code snippet that demonstrates how cells are styled:

    CalendarDayCellFilter weekendCellFilter = new CalendarDayCellFilter();
    weekendCellFilter.IsWeekend = new Java.Lang.Boolean(true);
    CalendarDayCellStyle weekendCellStyle = new CalendarDayCellStyle();
    weekendCellStyle.Filter = weekendCellFilter;
    weekendCellStyle.TextColor = new Java.Lang.Integer(Color.Red.ToArgb());
    calendarView.AddDayCellStyle(weekendCellStyle);


    You can read more about cell styling here: 

    http://docs.telerik.com/devtools/android/controls/calendar/calendar-customizations#defining-set-of-cell-styles

    I hope this helps.

    Regards,
    Deyan
    Telerik by Progress
    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. DevCraft banner
  4. Maurits
    Maurits avatar
    7 posts
    Member since:
    May 2016

    Posted 05 Jul in reply to Deyan Link to this post

    Hi Deyan,

    This doesn't really help me, since the filter does not allow you to check for week numbers, only for weekends. I need a little bit more information please.

  5. Answer
    Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 08 Jul Link to this post

    Hello Maurits,

    Thanks for writing back.

    You will need to set the CellType property to instruct the filter which cells to style as the documentation states:

    "

    Here are the methods for the CalendarDayCellFilter which allow you to filter the cells that use a certain style:

    • setCellType - to apply style to dates, dayNames, weekNumbers or titles; default is Date
    • setIsSelected - to apply style only to cells which are selected
    • setIsFromCurrentMonth - to apply style only to cells from the current month and not to the visible cells from the previous and the next months
    • setIsToday - to apply the style only to the today cell
    • setIsWeekend - to apply the style only to cells used to display Saturdays and Sundays
    • setCustom - if none of the above works for you, you can add a custom function which based on a passed cell, returns true or false, depending on whether the cell should be customized.
    "

    Please take a look at the article I pasted in my previous post for more information.

    Regards,
    Deyan
    Telerik by Progress
    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
  6. Maurits
    Maurits avatar
    7 posts
    Member since:
    May 2016

    Posted 09 Jul in reply to Deyan Link to this post

    Thank you Deyan for pointing out the setCellType method (or CellType property in C#). This did the trick for me.
Back to Top
DevCraft banner