Closed marabita closed 9 years ago
You can use app:mcv_dateTextAppearance
(or the Java setter) to do this. I still need to document how this should be done ( #76 ), but for now you can copy the default implementation and modify as you need. Essentially you need to supply a android:textColor
that is a color state list with your desired colors.
Add a style:
<style name="TextAppearance.MyCustomDay" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/my_custom_day_color</item>
</style>
and create color/my_custom_day_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="@android:integer/config_shortAnimTime"
android:exitFadeDuration="@android:integer/config_shortAnimTime">
<item android:state_checked="true" android:color="SELECTION_COLOR" />
<item android:state_pressed="true" android:color="SELECTION_COLOR" />
<item android:state_enabled="false" android:color="#808080" />
<item android:color="@android:color/black" />
</selector>
then set app:mcv_dateTextAppearance="@style/TextAppearance.MyCustomDay"
Hi @dandc87, Thanks for very fast response I resolved using a decoration specific to change the selected date:
public class OneDayDecorator implements DayViewDecorator {
private CalendarDay date;
public OneDayDecorator() {
date = CalendarDay.today();
}
@Override
public boolean shouldDecorate(CalendarDay day) {
return date != null && day.equals(date);
}
@Override
public void decorate(DayViewFacade view) {
view.addSpan(new ForegroundColorSpan(Color.RED));
}
/**
* We're changing the internals, so make sure to call {@linkplain MaterialCalendarView#invalidateDecorators()}
*/
public void setDate(Date date) {
this.date = CalendarDay.from(date);
}
}
And adding on calendar view:
mCalendarView.addDecorator(mSelectedDayDecorator);
@Marabita! your solution works for me! thanks!
thanks @Marabita , I has been highlight current day, i happy
Great its work! and if u want use custom color I add context in OneDayDecorator and use
view.addSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.celeste)));
Hello @Marabita . I am trying to use your solution but I guess I do not fully understand your solution. I created decorator class and set it to my calendar view but the result is still the same. Can you help me please..
@dandc87 Works like a charm. Thanks!
@marcello-marabita-mblabs Thanks it works for me.
First thanks for the component, is excellent and very complete.
I'm trying to change the text color of the selected day and just found the setSelectionColor property but it changes the color of the round form.