Closed acolombo11 closed 5 years ago
I played around with example 2 to achieve something like this. Since CalendarView
extends from RecyclerView
, I added a scroll listener and just updated a view which I put above the weekday texts on the toolbar using calendarView.findFirstVisibleMonth()
.
Here's the result:
Here's the code:
calendarView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
calendarView.findFirstVisibleMonth()?.let { calendarMonth ->
stickyHeaderTextView.text = "${calendarMonth.yearMonth.month.name.toLowerCase().capitalize()} ${calendarMonth.year}"
}
}
})
It's not exactly what I wanted because using the previously mentioned RecyclerView.ItemDecoration the current header gets pushed away from the previous one. But still the result you helped me getting is totally acceptable, so thank you really much.
Here's the result: .
Glad I was able to help! Closing this now.
In my vertical scrolling calendar (similar to example2) I would like to have sticky headers. I've tried using this solution making a custom RecyclerView.ItemDecoration but, with "CalendarAdapter" being internal and not using the "viewType" parameter, I find it really difficult to make it work . Do you have any suggestions in how to implement such a thing? Internal or external to the library I could implement it myself, I'm just seeking some advice.