prolificinteractive / material-calendarview

A Material design back port of Android's CalendarView
https://prolificinteractive.github.io/material-calendarview/
MIT License
5.92k stars 1.32k forks source link

first time initialize the calendar, selected circle will expand to parent width and height #1128

Open jerrylkc opened 2 years ago

jerrylkc commented 2 years ago

when setTileWidth or setTileHeight, and setSelectedDate the first time we initialize the calendar, the selected circle expands to view width and height, like oval shape, but after a while, it returns to a normal circle.

I have tried using DayViewDecorator, and set setSelectionDrawable for custom drawable with fixed size, but no luck.

Mor1995 commented 2 years ago

I facing the same problem, I found that cause of the problem is onDraw() method called before onLayout(). The rect is unset in onDraw()method, So the cicle will filling rect and you see it like oval shape.After a while it back to normal circle because it relayout and set correct width and height.

In my code, I delete invalidateDecorators() called in onDateSelected().

    widget.setOnDateChangedListener(new OnDateSelectedListener() {
      @Override
      public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
    //    widget.invalidateDecorators();
      }
    });

It's work for me.