Giter Club home page Giter Club logo

Comments (4)

rAseri avatar rAseri commented on June 2, 2024

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.

wyzard avatar wyzard commented on June 2, 2024

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.

wyzard avatar wyzard commented on June 2, 2024

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.

wyzard avatar wyzard commented on June 2, 2024

Ok, my fault. It was a positioning problem. :)

from crunchycalendar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.