Horizontal Calendar
A material horizontal calendar view for Android based on RecyclerView.
Installation
The library is hosted on jcenter, add this to your build.gradle:
Prerequisites
The minimum API level supported by this library is API 14 (ICE_CREAM_SANDWICH).
Usage
- Add
HorizontalCalendarView
to your layout file, for example:
- In your Activity or Fragment, define your start and end dates to set the range of the calendar:
- Then setup
HorizontalCalendar
in your Activity through its Builder:
- Or if you are using a Fragment:
- To listen to date change events you need to set a listener:
- You can also listen to scroll and long press events by overriding each perspective method within HorizontalCalendarListener:
Customization
- You can customize it directly inside your layout:
- Or you can do it programmatically in your Activity or Fragment using
HorizontalCalendar.Builder
:
More Customizations
Months Mode
HorizontalCalendar can display only Months instead of Dates by adding mode(HorizontalCalendar.Mode.MONTHS)
to the builder, for example:
Events
A list of Events can be provided for each Date which will be represented as circle indicators under the Date with:
Reconfiguration
HorizontalCalendar configurations can be changed after initialization:
- Change calendar dates range:
- Change default(not selected) items style:
- Change selected item style:
- Change formats, text sizes and selector color:
Important
Make sure to call horizontalCalendar.refresh();
when you finish your changes
Features
- Disable specific dates with
HorizontalCalendarPredicate
, a unique style for disabled dates can be specified as well withCalendarItemStyle
:
- Select a specific Date programmatically with the option whether to play the animation or not:
- Check if a date is contained in the Calendar:
- Check if two dates are equal (year, month, day of month):
- Get number of days between two dates: