I already use Decorators to add a background to certain dates, but I would like in thoses dates, to change the color of the text.
For example : I put decorators on dates : 5,6,7, i would like the text color on the 5,6,7 to be in White, and the others dates text color to be black.
Is it possible ?
Can someone explain me how to do it ?
Thanks.
How did you implement Decorators can you please help me.
I m a newbie in Android and i cannot implement decorator.
Any help would be appreciated.
Can we set decorator to a set of Date List ???
In my case i have a list of events and i need to show them in calendar with different colors.
Check the sample App, and personnaly i change the constructor of my Decorator, I pass a Drawable in parameters, and then in the Decorate I add the Drawable in background.
With this, I use the same Decorator class, but with differents Drawables for differents colors.
My question is still not solved so I ask for it again :
I already use Decorators to add a background to certain dates, but I would like in thoses dates, to change the color of the text.
For example : I put decorators on dates : 5,6,7, i would like the text color on the 5,6,7 to be in White, and the others dates text color to be black.
Is it possible ?
Can someone explain me how to do it ?
Thanks.
Try to use
@Override public void decorate(DayViewFacade view) {
view.addSpan(new RelativeSizeSpan(1.8f)); // for TextSize
view.addSpan(new ForegroundColorSpan(Color.WHITE)); // for TextColor
}
public class EventDecorator implements DayViewDecorator {
private final int color;
private final HashSet<CalendarDay> dates;
private Drawable drawable;
private Context context;
public EventDecorator(Context context,int color, Collection<CalendarDay> dates) {
this.context = context;
this.color = color;
this.dates = new HashSet<>(dates);
drawable = ContextCompat.getDrawable(context,R.drawable.ic_account_circle);
}
@Override
public boolean shouldDecorate(CalendarDay day) {
return dates.contains(day);
}
@Override
public void decorate(DayViewFacade view) {
view.addSpan(new ForegroundColorSpan(color));
//view.setSelectionDrawable(drawable);
}
@ValeriyMakarshin Thanks!
Most helpful comment
Try to use