A simple library which gives you custom design CalendarView with dialog functionality and event handlers.

Overview

CalendarView

A simple library which gives you custom design CalendarView with dialog functionality and event handlers.

1: CalendarView

Demo Screen

1.1: Import Library

implementation 'com.github.shahzadafridi:CalenderView:1.1.5'

Method A

1.2: XML File

">
<com.shahzadafridi.calendarview.CalendarView
        android:id="@+id/calendar_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

1.3: Kotlin Code

  var selectedDate = Calendar.getInstance()
  var calendarView = findViewBydId(R.id.calendar_view)

  calendarView.builder()
      .withYearPanel(
          dateFormat = "yyyy",
          textColor = R.color.greyed_out,
          textSize = 42f,
          font = R.font.titillium_web_semibold
      )
      .withBackButton(
          isShow = true,
          background = R.drawable.ic_up_round
      )
      .withMonthPanel(
          font = R.font.titillium_web_semibold,
          textSize = 20f,
          selectedTextColor = R.color.black,
          unSelectedTextColor = R.color.greyed_out,
          background = R.color.white,
          months = months
      )
      .withWeekPanel(
          font = R.font.titillium_web_semibold,
          textColor = R.color.black,
          textSize = 14f,
          background = R.color.white,
          weekDays = weekDays
      )
      .withDayPanel(
          font = R.font.titillium_web_semibold,
          textColor = R.color.black,
          textSize = 16f,
          selectedTextColor = R.color.white,
          selectedBackground = R.drawable.ic_green_oval,
          background = R.color.white
      )
      .withCalenderViewBg(
          background = R.drawable.rect_lr_wround_bg
      )
      .withUpdateSelectDate(selectedDate!!) //It's required when using kotlin Instead of XML Configuration.
      .withEvents(
          events = events,
          eventDotColor = R.color.green
      )
      .buildCalendar()

Extra

You can set margin of Year, Month, Week and Day panel/section.

      .withYearPanleMargin(
         top = 12,
         bottom = 15,
         left = 12,
         right = 12
      )
      .withMonthPanleMargin(
         top = 12,
         bottom = 15,
         left = 12,
         right = 12
      )
      .withWeekPanelMargin(
         top = 12,
         bottom = 15,
         left = 12,
         right = 12
      )
      .withDayPanelMargin(
         top = 12,
         bottom = 15,
         left = 12,
         right = 12
      )

OR

Method B

1.2: XML File

">
    <com.shahzadafridi.calendarview.CalendarView
        android:id="@+id/calendar_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:is_back_button_show="true"
        app:back_button_bg="@drawable/ic_up_round"
        app:year_date_Formate="MM YYYY"
        app:year_text_font="@font/titillium_web_semibold"
        app:year_text_clr="@color/cblack"
        app:year_text_size="12dp"
        app:month_txt_size="8dp"
        app:month_font="@font/titillium_web_semibold"
        app:month_unselect_txt_clr="@color/white"
        app:month_selected_txt_clr="@color/green"
        app:month_bg="@color/black"
        app:week_font="@font/titillium_web_semibold"
        app:week_bg_clr="@color/black"
        app:week_txt_clr="@color/white"
        app:week_txt_size="6dp"
        app:day_bg="@color/white"
        app:day_select_bg="@drawable/ic_green_oval"
        app:day_text_size="5dp"
        app:day_select_txt_clr="@color/white"
        app:day_txt_clr="@color/cblack"
        app:day_font="@font/titillium_web_semibold"
        app:cv_bg="@drawable/rect_lr_wround_bg"/>

1.3: Kotlin Code

  var calendarView = findViewBydId(R.id.calendar_view)

  calendarView.builder()
      .withEvents(events, R.color.green)
      .buildCalendar()

1.4: CalendarView Event Handles

calendarView.setEventHandler(object : CalenderViewInterface.EventHandler {

    override fun onDayClick(view: View?, date: Date, position: Int) {
        val df = SimpleDateFormat.getDateInstance()
        //Required for selected date background. Ignore If you are using XML configuration.
        selectedDate = Calendar.getInstance().apply {
           time = date
        }
        Toast.makeText(this@MainActivity, df.format(date), Toast.LENGTH_SHORT).show()
        Log.e("TEST", "onDayClick")
    }

    override fun onDayLongClick(view: View?, date: Date, position: Int) {
        val df = SimpleDateFormat.getDateInstance()
        Toast.makeText(this@MainActivity, df.format(date), Toast.LENGTH_SHORT).show()
        Log.e("TEST", "onDayLongClick")
    }

    override fun onBackClick(view: View?) {
        Log.e("TEST", "onBackClick")
        dialog?.dismiss()
    }

    override fun onMonthClick(view: View?, month: String, position: Int) {
        Toast.makeText(this@MainActivity, month, Toast.LENGTH_SHORT).show()
        Log.e("TEST", "onMonthClick")
    }
})

2: CalendarViewDialog

Demo Screen

2.1: Kotlin Code

        var dialog = CalendarViewDialog(this) // this is context
        dialog!!.setCancelable(false)
        dialog!!.show()
        var calendarView = dialog!!.getCalendarView()
        // Follow 1.3 Step. It is same configuration.

Methods Info

  • withYearPanel can change Date formate, Text Color, Text Size, Text Font
  • withBackButton can close CalendarView with Back Button
  • withMonthPanel can change the month Text font, Text Size, Selected Text Color, Unselected Text Color, month names, Background of month layout
  • withWeekPanel can change the week days Text font, Text Color, Text Size,days name, Background of week layout
  • withDayPanel can change the day Text font, Text Color, Text Size, Selected background, Selected Text Color, Background of day
  • withCalenderViewBg can change the CalendarView background
  • withEvents can gives events dates to calendarView which shows small dot indcaotr below of day
  • withUpdateSelectDate This method will change the background color of selected date. It's required when using Kotlin code instead of XML configuration

Watch Demo Video

Logo

Click me: @realtimecoding

You can subscribe the channel for more android related stuffs as I am planning to work on android tutorials.

Contributing

Pull requests are welcomed!

License

MIT

You might also like...
Asimov-flagz-kt - Feature flags library based on Togglz library

Asimov Flagz Feature flags library based on Togglz library. Installation Gradle

PopTimer is a simple, lightweight Rubik's Cube timer for Android
PopTimer is a simple, lightweight Rubik's Cube timer for Android

PopTimer (developing) PopTimer is a simple, lightweight Rubik's Cube timer, localization support, It uses the TNoodle library to generate scramble seq

Multiplatform Date and time library for Kotlin
Multiplatform Date and time library for Kotlin

Klock is a Date & Time library for Multiplatform Kotlin. It is designed to be as allocation-free as possible using Kotlin inline classes, to be consis

A Kotlin Multiplatform library for working with dates and times

Island Time A Kotlin Multiplatform library for working with dates and times, heavily inspired by the java.time library. Features: A full set of date-t

Kmpcalendar - A calendar library and views written for kotlin multiplatform
Kmpcalendar - A calendar library and views written for kotlin multiplatform

KMPCalendarView Minimal Kotlin Multiplatform project with SwiftUI, Jetpack Compo

Joda-Time library with Android specialization

Android has built-in date and time handling - why bother with a library? If you've worked with Java's Date and Calendar classes you can probably answer this question yourself, but if not, check out Joda-Time's list of benefits.

Android NTP time library. Get the true current time impervious to device clock time changes
Android NTP time library. Get the true current time impervious to device clock time changes

TrueTime for Android Make sure to check out our counterpart too: TrueTime, an NTP library for Swift. NTP client for Android. Calculate the date and ti

Android library for better Picker DialogFragments
Android library for better Picker DialogFragments

DialogFragments modeled after the AOSP Clock and Calendar apps to improve UX for picking time, date, numbers, and other things.

KotlinX multiplatform date/time library

kotlinx-datetime A multiplatform Kotlin library for working with date and time. See Using in your projects for the instructions how to setup a depende

Releases(v1.1.5)
Owner
Shahzad Afridi (Opriday)
Android Engineer.
Shahzad Afridi (Opriday)
Demo app for a horizontal schedule(event) calendar

This is a demo project that showcases a horizontally laid out calendar that shows events in a timeline fashion. It is not a library, just a reference implementation for curious developers.

Halil Ozercan 188 Dec 26, 2022
android library dialog month picker

RackMonthPicker android library dialog month picker Download Download via Maven: Add the JitPack repository to your build file <repositories> <rep

Kristiawan Adi L 41 Aug 13, 2022
Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling.

Android Week View Android Week View is an android library to display calendars (week view or day view) within the app. It supports custom styling. Fea

Raquib-ul Alam (Kanak) 3.4k Jan 3, 2023
A custom clock view with a circular slider.

Read this in other languages: English, δΈ­ζ–‡. ClockSlider A custom clock view with a circular slider. Supported Android Versions Android 4.0 Jelly Bean(A

Chien 5 Nov 13, 2022
An android library which provides a compact calendar view much like the one used in google calenders.

CompactCalendarView CompactCalendarView is a simple calendar view which provides scrolling between months. It's based on Java's Date and Calendar clas

SundeepK 1.5k Jan 7, 2023
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour

CustomizableCalendar This library allows you to create a completely customizable calendar. You can use CustomizableCalendar to create your calendar, c

MOLO17 216 Dec 6, 2022
πŸ“… Minimal Calendar - This calendar library is built with jetpack compose. Easy, simple, and minimal.

?? Minimal Calendar This calendar library is built with jetpack compose. Easy, simple, and minimal. Latest version The stable version of the library i

Minjae Kim 16 Sep 14, 2022
Tanya Gupta 1 Aug 16, 2022
A simple calendar with events, customizable widgets and no ads.

Simple Calendar A simple calendar with events and a customizable widget. A simple calendar with optional CalDAV synchronization. You can easily create

Simple Mobile Tools 3k Jan 4, 2023
A simple Cupcake Ordering App, choose flavor, pickup on a date, get order summary and send order via any other app.

Cupcake app This app contains an order flow for cupcakes with options for quantity, flavor, and pickup date. The order details get displayed on an ord

Akshat Khandelwal 0 Dec 23, 2021