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

Height doesn't adjust for each month with wrap_content on horizontal paged calendar #281

Closed
nikolasamardzija opened this issue Feb 11, 2021 · 14 comments

Comments

@nikolasamardzija
Copy link

nikolasamardzija commented Feb 11, 2021

Steps to reproduce

  1. I've added calendar view with wrap_content
<com.kizitonwose.calendarview.CalendarView
            android:id="@+id/cv_custom_calendar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            app:cv_dayViewResource="@layout/calendar_day"
            app:cv_hasBoundaries="true"
            app:cv_outDateStyle="none"
            app:cv_monthHeaderResource="@layout/calendar_header"
            app:cv_orientation="horizontal"
            app:cv_scrollMode="paged"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tv_month_year" />
  1. Open fragment for the first time, scroll to the previous month and height of the CalendarView stays the same even though the number of days and rows increased
  2. Open the same fragment again, resize works.

Note:
Is this an edge case because February starts on Monday with 28 days and it has 4 rows?
With fixed android:layout_height it shows all dates, but doesn't look nice with extra space at the bottom. Also, I can't find the right height that will show all days for every screen size.

Is there a possibility to have fixed size and spacing between rows to be auto-adjusted?

Device:
Samsung S8,
Samsung A5 2017

Video:
https://vimeo.com/user133404315/review/511093300/5daa85a221

@nikolasamardzija nikolasamardzija changed the title wrap_content doesn't get updated on horizontal paged calendar Height doesn't adjust for each month with wrap_content on horizontal paged calendar Feb 11, 2021
@kizitonwose
Copy link
Owner

Video: vimeo.com/user133404315/review/511093300/5daa85a221

This link is not working.

Is there a possibility to have fixed size and spacing between rows to be auto-adjusted?

I do not understand, could you explain a bit more?

@nikolasamardzija
Copy link
Author

nikolasamardzija commented Feb 12, 2021

@kizitonwose thanks for the reply.
Can you see this video? https://drive.google.com/file/d/11p5Bm1wIHH9PUsaAtnryVOL4nOX-qUVg/view?usp=sharing
I want to have CalendarView that will adjust its height based on the number of rows. That doesn't work on the video that I sent you. Do you know what could be the reason for this bug? Do you have some suggestions that I could try?

In case that you don't have suggestions for the problem mentioned above, I could try a workaround if you know the answer for that.
Create CalendarView that will have fixed height. Based on that fixed height CalendarView would adjust its row spacing. This is example on iOS with different calendar library https://drive.google.com/file/d/1eIiTt95Eu-jd_ywih7lLznnn9I8EgXuu/view?usp=sharing

@kizitonwose
Copy link
Owner

Ok, that's not possible. The calendar adjusts its height from the bottom when a month has fewer rows than the previous one. The spreading behavior in the second video looks rather odd to me, but not possible anyways.

@kizitonwose
Copy link
Owner

The library uses a linear layout internally, so if you really want this, willing to fork the project, and the calendar has a fixed height, then in the binding logic, you'd just divide the remaining bottom space by the number of visible rows and set it as a divider on the linear layout.

@nikolasamardzija
Copy link
Author

Hi @kizitonwose, sorry for the confusion, please don't focus on my second question about the spreading of rows. It was just an alternative that I mentioned if we don't solve the first problem.

Focus on the problem in the first video where you can see that I can't see all the rows because they are cut off. CalednarView is not resized automatically with wrap_content so it shows all rows.

@kizitonwose
Copy link
Owner

Ok, please check with version 1.0.2 which was released yesterday, this issue is likely fixed.

@nikolasamardzija
Copy link
Author

Hey @kizitonwose, thanks for keeping the library up to date.
I now have a different problem, and I think it's similar to issue #283

Take a look at a video, you can see that some days are missing.
https://drive.google.com/file/d/1_D8Z81k-GF8zecjNH78AxBvMIdclg_n1/view?usp=sharing

@kizitonwose
Copy link
Owner

Are you reloading the calendar every time it scrolls to a new month?

@nikolasamardzija
Copy link
Author

Yes, I call cv_custom_calendar.notifyCalendarChanged()

@kizitonwose
Copy link
Owner

Why?

@nikolasamardzija
Copy link
Author

Every time I scroll I have to pull data from the server, after that I have to show that data on the calendar for that month.

In bind method I keep logic that will render a calendar based on that list from the server, so I have to recall that.

I tested now without calling notifyCalendarChanged() and the same problem is still happening. Some days start to be invisible after scrolling back to that month.

@nikolasamardzija
Copy link
Author

Hi @kizitonwose, a reminder in case you missed my last comment. Do you have an idea what could go wrong, maybe we can take a look at the library together to find the source of the bug and to fix it?

@kizitonwose
Copy link
Owner

Are you sure this is not an issue with your binding logic? If you can set up one of the examples to reproduce this, then I can take a look directly.

@nikolasamardzija
Copy link
Author

@kizitonwose You solved the first problem with the library, the second one with disappearing dates was on my side in binding logic, it's fixed now.

Thanks for your help!

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

2 participants