CalendarView

Additional

Language
Kotlin
Version
2.5.0-beta01 (Dec 14, 2023)
Created
Apr 20, 2019
Updated
Jan 31, 2024
Owner
Kizito Nwose (kizitonwose)
Contributors
Paolo Rotolo (paolorotolo)
Kizito Nwose (kizitonwose)
Vasili Chyrvon (Jeevuz)
germinator
Jan Bína (janbina)
Luis Cortes (luis-cortes)
0xflotus
Marcin Simonides (msimonides)
evjava
Alex Petrakov (alex-petrakov)
Ángel Alanís (AngelAlanis)
L. Choi (cccc-22)
12
Activity
Badge
Generate
Download
Source code

Calendar

A highly customizable calendar library for Android, backed by RecyclerView for the view system, and LazyRow/LazyColumn for compose.

With this library, your calendar will look however you want it to.

Features

  • Single, multiple or range selection - Total flexibility to implement the date selection whichever way you like.
  • Week or month mode - Show a week-based calendar, or the typical month calendar.
  • Disable desired dates - Prevent selection of some dates by disabling them.
  • Boundary dates - Limit the calendar date range.
  • Custom date view/composable - Make your day cells look however you want, with any functionality you want.
  • Custom calendar view/composable - Make your calendar look however you want, with whatever functionality you want.
  • Custom first day of the week - Use any day as the first day of the week.
  • Horizontal or vertical scrolling calendar.
  • HeatMap calendar - Suitable for showing how data changes over time, like GitHub's contribution chart.
  • Month/Week headers and footers - Add headers/footers of any kind on each month/week.
  • Easily scroll to any date/week/month on the calendar via swipe actions or programmatically.
  • Use all RecyclerView/LazyRow/LazyColumn customizations since the calendar extends from RecyclerView for the view system and uses LazyRow/LazyColumn for compose.
  • Design your calendar however you want. The library provides the logic, you provide the views/composables.

Sample project

It's important to check out the sample app. There are lots of examples provided for both view and compose implementations. Most techniques that you would want to implement are already done in the examples.

Download the sample app here

View the sample app's source code here

Setup

The library uses java.time classes via Java 8+ API desugaring for backward compatibility since these classes were added in Java 8.

Step 1

This step is required ONLY if your app's minSdkVersion is below 26. Jump to step 2 if this does not apply to you.

To set up your project for desugaring, you need to first ensure that you are using Android Gradle plugin 4.0.0 or higher.

Then include the following in your app's build.gradle file:

android {
  defaultConfig {
    // Required ONLY if your minSdkVersion is below 21
    multiDexEnabled true
  }

  compileOptions {
    // Enable support for the new language APIs
    coreLibraryDesugaringEnabled true
    // Set Java compatibility (version can be higher if desired)
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  kotlinOptions {
    // Also add this for Kotlin projects (version can be higher if desired)
    jvmTarget = "1.8"
  }
}

dependencies {
  coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:<latest-version>'
}

You can find the latest version of desugar_jdk_libs here.

Step 2

Add the desired calendar library (view or compose) to your app build.gradle:

dependencies {
  // The view calendar library
  implementation 'com.kizitonwose.calendar:view:<latest-version>'

  // The compose calendar library
  implementation 'com.kizitonwose.calendar:compose:<latest-version>'
}

You can find the latest version of the library on the maven central badge above.

Snapshots of the development version are available in Sonatype’s snapshots repository.

If you're upgrading from version 1.x.x to 2.x.x, see the migration guide.

For the compose calendar library, ensure that you are using the library version that matches the Compose UI version in your project. If you use a version of the library that has a higher version of Compose UI than the one in your project, gradle will upgrade the Compose UI version in your project via transitive dependency.

Compose UI Calendar Library
1.2.x 2.0.x
1.3.x 2.1.x - 2.2.x
1.4.x 2.3.x
1.5.x 2.4.x
1.6.x 2.5.x

Usage

You can find the relevant documentation for the library in the links below.

View-based documentation Compose documentation

Share your creations

Made a cool calendar with this library? Share an image here.

Contributing

Found a bug? feel free to fix it and send a pull request or open an issue.

License

Calendar library is distributed under the MIT license. See LICENSE for details.