Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monthly calendar view is not showing all days #232

Closed
batadamnjanovic opened this issue Oct 28, 2020 · 19 comments
Closed

Monthly calendar view is not showing all days #232

batadamnjanovic opened this issue Oct 28, 2020 · 19 comments

Comments

@batadamnjanovic
Copy link

batadamnjanovic commented Oct 28, 2020

Version: 0.4.5
Device: Xiaomi Mi A3, Android 10, 720x1560

When swiping through months, specifically when April is selected, calendar does not show all days. I've tried with notifyMonthChanged(month: YearMonth) but without success. Please advise.

Recording: https://drive.google.com/file/d/1fXa9UL3pae6B-SiUKEDGZ9-AJ9OB79WS/view

And an image:
calendarbug

@kizitonwose
Copy link
Owner

This has been fixed previously so I'm not sure why you're still experiencing the issue. It would be nice if you can let me know how to reproduce this.

@batadamnjanovic
Copy link
Author

batadamnjanovic commented Nov 3, 2020

@kizitonwose
It looks like it is happening when I put a margin on a Calendar view.

android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"

It works without margin. But design requires to set margin because of the arrows.

Do you have a suggestion how should I handle this?

@kizitonwose
Copy link
Owner

Maybe use padding instead?

@batadamnjanovic
Copy link
Author

batadamnjanovic commented Nov 4, 2020

When using padding, calendar does not show all days in a week, it has an offset. I've tried different combinations.
I managed to work on my device with margin=16dp, but who knows how it will work on other devices

@kizitonwose
Copy link
Owner

A rather temporary fix would be to wrap the calendar in a framelayout and apply the margin or padding to the framelayout instead.

@batadamnjanovic
Copy link
Author

I've also tried that, but without success.

@batadamnjanovic
Copy link
Author

batadamnjanovic commented Nov 6, 2020

Device is Xiaomi Mi A3, Android 10, 720x1560

Update: I've tried on other emulators and it is working. Don't know what the problem is with Xiaomi Mi A3

@batadamnjanovic
Copy link
Author

So, I've debugged more, and it turns out that it is working with margin 21dp. Somehow margin 20dp is a magic number :)).
Resolutions that experience this problems are: 720x1560, 768x1280

@kizitonwose
Copy link
Owner

Ok, this is quite hilarious. I don't even know what to do here.

@kizitonwose
Copy link
Owner

So ...19 and 21... work fine on all devices but 20dp is where the issue happens?

@batadamnjanovic
Copy link
Author

batadamnjanovic commented Nov 8, 2020

Yes, and not on all devices :) I've tested on emulators and these two resolutions have the same problem: 720x1560, 768x1280.
I will try to reproduce it on some of your examples and will let you know

@batadamnjanovic
Copy link
Author

batadamnjanovic commented Nov 8, 2020

I've tested on your Example1Fragment.

If you want to reproduce this, create a virtual device with 720x1560.
In CalendarUtils in daysOfWeekFromLocale() method, change the locale to be WeekFields.of(Locale.UK).firstDayOfWeek - to set a Monday as a first day of week.
And on com.kizitonwose.calendarview.CalendarView set marginStart and marginEnd to 20dp.
And try again with 21dp, it will work :)

@batadamnjanovic
Copy link
Author

@kizitonwose
Another thing. Months can have 4, 5 or 6 rows. Can I somehow know the number of rows in advance for the current month in order to smoothly animate calendar from weekly to monthly view?
Screen Shot 2020-11-09 at 11 46 56 PM

@kizitonwose
Copy link
Owner

I've tested on your Example1Fragment.

If you want to reproduce this, create a virtual device with 720x1560.
In CalendarUtils in daysOfWeekFromLocale() method, change the locale to be WeekFields.of(Locale.UK).firstDayOfWeek - to set a Monday as a first day of week.
And on com.kizitonwose.calendarview.CalendarView set marginStart and marginEnd to 20dp.
And try again with 21dp, it will work :)

I'll take a look soon. Thankfully you have something that works temporarily.

@kizitonwose
Copy link
Owner

Another thing. Months can have 4, 5 or 6 rows. Can I somehow know the number of rows in advance for the current month in order to smoothly animate calendar from weekly to monthly view?

val rowCount = calendarView.findFirstVisibleMonth()?.weekDays?.size

@batadamnjanovic
Copy link
Author

batadamnjanovic commented Nov 10, 2020

val rowCount = calendarView.findFirstVisibleMonth()?.weekDays?.size

It's not working as expected. Sometimes it returns a wrong value for the rowCount.

@kizitonwose
Copy link
Owner

It's not working as expected. Sometimes it returns a wrong value for the rowCount.

Could you explain further?

@Buddypas
Copy link

The same thing happened to me, but calling notifyCalendarChanged in the month scroll listener fixed the issue for me. Also, since in its base the calendar is a RecyclerView, if you are toggling the visibility of views in a certain month they can get recycled and stay hidden in other months, so in the day binder init block make sure to set the proper visibility. Hope this helps.

Repository owner deleted a comment from asthagarg2428 Jan 11, 2021
@kizitonwose
Copy link
Owner

I'm closing this issue as the main problem is addressed. The idea that 20dp breaks on a 720x1560 device is not something I want to investigate 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants