问题
Is there a way to display a calendarview for 2 weeks at a time instead of the full month(4 weeks)? Please see the attached images.
I would still like to retain the gestures
- Scrolling left/right will change months
- Scrolling up/down will show me the following weeks.
Hoping that someone can point me in the right direction. Thank you!
回答1:
for this what I did was the following
- Create View pager (to mimic swiping left and right of a calendar)
- In the view pager adapter, use fragments (MonthFragment) per page that holds a Gridview. Make sure that your Gridview only shows 2 rows at a time
- Use an adapter to populate the Gridview elements with the dates. *there are examples online
- Implement a snap function for when you are scrolling the gridview vertically by setting an onTouchListener to the Gridview and snapping it up or down depending on the current movement.
This isn't perfect, but this solved my problem. Hoping that it will help others.
回答2:
I would imagine subclassing the CalendarView class to create something like "FortnightCalendarView" would be your best bet. Then you can override the display to limit it to 2 weeks. I would still use the left/right buttons to navigate fortnights instead of months, or possibly create an addition set of left-right buttons.
来源:https://stackoverflow.com/questions/38953036/android-calendar-view-show-only-2-weeks