Hello,
First of all, I really appreciate all of your hard work in putting together this great library. We've been most fortunate to be able to use it in our project because it's been of great help. I've been going over all the documentation to customize the library to fit some requirements but have run into an issue as I'm not able to change the typeface of the weekday labels (Sun/Mon/etc).
I was able to work around this issue for the headers by calling .setTopbarVisible(false); and using my own label inside a FrameLayout but I was wondering if there is anything I could do to set a custom typeface for the weekday labels.
Hi @firoze did you try using WeekDayFormatter? It allows you to return a CharSequence for each day of the week.
@ivandeskov that helped me! I was able to set TypeFaceSpan and set the custom font. Thanks! I'll close this issue.
Can you post your code please ?
materialCalendarView.setWeekDayFormatter(dayOfWeek -> {
SpannableString daySpan = new SpannableString(days[dayOfWeek - 1]);
daySpan.setSpan(new TypefaceSpan(getApplicationContext(), "Regular-Book.ttf"), 0, daySpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
daySpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getApplicationContext(), R.color.dateStroke)), 0, daySpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
daySpan.setSpan(new RelativeSizeSpan(1.5f), 0, daySpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return daySpan;
});
Thank you @firoze
In my case changing color / font is not working i'm using like this
calendarView.setWeekDayFormatter(new WeekDayViewDecorator(this));
@Override
public CharSequence format(int dayOfWeek) {
String[] daysOfWeek = context.getResources().getStringArray(R.array.custom_weekdays);
SpannableString daySpan = new SpannableString(daysOfWeek[dayOfWeek - 1]);
daySpan.setSpan(new TypefaceSpan(context.getString(R.string.opensans_bold)), 0, daySpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
daySpan.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, R.color.red)), 0, daySpan.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return daySpan;
}
any suggestion ?
I found the problem adding
to the textview mess up with font , hope it will help someone
is there a quicker way to format all typefaces? Header, Dates, Days ?
Most helpful comment