MaterialCalendarView is a prettier and simpler, material design calendar that allows full customization and it's backwards compatible with API 19+.
Gradle
- Add it in your root build.gradle at the end of repositories:
repositories {
maven {
url "https://jitpack.io"
}
}
- Add the dependency:
dependencies {
implementation 'com.github.LeeBoonKong:Material-CalendarView:1.15'
}
In your layout.xml file:
<com.leeboonkong.materialcalendarview.view.CalendarView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
</com.leeboonkong.materialcalendarview.view.CalendarView>
This example shows all the possible customization around Material Calendar View:
<com.leeboonkong.materialcalendarview.view.CalendarView
android:id="@+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:calendarIsMultiSelectDayEnabled="false"
app:calendarIsOverflowDatesVisible="true"
app:calendarBackgroundColor="@color/colorPrimary"
app:calendarTitleTextColor="@color/colorAccent"
app:calendarCurrentDayTextColor="@color/white"
app:calendarDayOfWeekTextColor="@color/grey"
app:calendarDayOfMonthTextColor="@android:color/white"
app:calendarDisabledDayBackgroundColor="@color/colorPrimary"
app:calendarDisabledDayTextColor="@android:color/darker_gray"
app:calendarSelectedDayBackgroundColor="@color/colorAccent"
app:calendarTitleBackgroundColor="@color/colorPrimary"
app:calendarWeekBackgroundColor="@color/colorPrimary"
app:calendarCurrentDayBackgroundColor="@color/teal500"
app:calendarWeekendTextColor="@color/colorAccent"
app:calendarButtonBackgroundColor="@color/colorAccent">
</com.leeboonkong.materialcalendarview.view.CalendarView>
Then, in your Activity.java or Fragment.java initialize the calendar:
calendarView = (CalendarView) findViewById(R.id.calendar_view);
calendarView.shouldAnimateOnEnter(true)
.setFirstDayOfWeek(Calendar.MONDAY)
.setOnDateClickListener(this::onDateClick)
.setOnMonthChangeListener(this::onMonthChange)
.setOnDateLongClickListener(this::onDateLongClick)
.setOnMonthTitleClickListener(this::onMonthTitleClick);
if (calendarView.isMultiSelectDayEnabled()) {
calendarView.setOnMultipleDaySelectedListener(this::onMultipleDaySelected);
}
calendarView.update(Calendar.getInstance(Locale.getDefault()));
Enjoy your new, beautiful, Materially-Designed calendar!
If you found a bug, or questions, you can open an issue at this github repository.
Of course, if you see something that you want to upgrade from this library, or a bug that needs to be solved, PRs are welcome!
Currently me(LeeBoonKong) is the only one maintaining this repository and fixing bugs, this is an open source project forked from https://github.com/BlackBoxVision/material-calendar-view, but the original was not maintained anymore.
If you would like to contribute you can:
- Write documentations for this project.
- Fix bugs, add new features and maintain this project.
Your Github username will be included in the Developers and Maintainers section.
LeeBoonKong
Distributed under the MIT license. See LICENSE for more information.