Comments (4)
Hi and thank you!
Out of the box you can define your custom background color for disabled days using resources. Unfortunately conditional background color for disabled days is not supported.
But, as a workaround, you could try to define your custom RecyclerView.ItemDecoration
class to decorate some specific days that you want. In the library there is a helper AbsDateItemDecoration
class that may help you to add some custom decorations for the specific days. Create your item decorator that extends the AbsDateItemDecoration
class. In the decorateDateView
method you could implement your own custom decoration logic for the specific days.
Let me know if it helps you.
from crunchycalendar.
Thank you for your answer. I found the addCustomItemDecoration method, but I had difficulties to preserve the original appearance (font size, text position etc. is perfect for me, the only thing that I want to change is the background color).
Anyhow it seems to be good for me, thanks for your help.
from crunchycalendar.
Sorry, it doesn't work for me. I can 'change' the background color of the cell, but I can't draw the day of month text on it.
Do you have a working example maybe? This is my draft so far:
`
private class CustomItemDecoration extends AbsDateItemDecoration {
@Override
public void decorateDateView(@NotNull Canvas canvas, @NotNull CalendarDate calendarDate, @NotNull Rect rect) {
DisplayMetrics displayMetrics = ReservationActivity.this.getResources().getDisplayMetrics();
int strokeWidth = Math.round(1f * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setColor(Color.LTGRAY);
paint.setStrokeWidth(strokeWidth);
TextPaint paint2 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
paint2.setColor(Color.RED);
if (calendarDate.getDayOfMonth() == 14) {
canvas.drawRect(rect.left + strokeWidth, rect.top + strokeWidth, rect.right - strokeWidth, rect.bottom - strokeWidth , paint);
//canvas.drawText(String.valueOf(calendarDate.getDayOfMonth()), rect.width() / 2, rect.height() / 2, paint2);
canvas.drawText("Test", rect.width() / 2f, rect.height() / 2f, paint2);
}
}
}
`
from crunchycalendar.
Ok, my fault. It was a positioning problem. :)
from crunchycalendar.
Related Issues (20)
- create event in calendar HOT 7
- Date Range Selection and dateSelectionFilter HOT 2
- Not scrolling to current day. HOT 8
- Translation HOT 2
- How to set a specific color background for specific dates? HOT 1
- OnDateClickListener Method In Java
- How to select and deselect multiple dates in month HOT 3
- Is it possible to go to next or previous month instead of year when using the arrows that are next to month? HOT 1
- Is it possible to add some events in calendar? HOT 1
- Проверка выбора даты HOT 1
- Impossible to customize some colors HOT 2
- how to disable date in range mode
- Date scrolling issue
- Version 2.1.0 is missing on jCenter/Maven
- Make example of getPreselectedDates() and getDatesIndicators() in main page HOT 1
- How can I add custom coloured indicators?
- How to change view to only One Months.
- Sample App not available in Google Play for LineageOS 19.1 (Android 12) HOT 1
- [Question] Good calendar apps utilizing CrunchyCalendar?
- Crash in CalendarDateView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crunchycalendar.