Skip to content

jevon-putra/Custom-Calendar

Repository files navigation

Custom Calendar View

Screenshot 2023-12-23 at 15 28 34 Screenshot 2023-12-23 at 15 46 14 Screenshot 2023-12-23 at 15 38 30 Screenshot 2023-12-23 at 16 06 54
  1. Step one add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url = uri("https://www.jitpack.io" )  }
    }
}
  1. Step two Add the dependency:
dependencies {
  implementation("com.github.JOOctp:Custom-Calendar:1.0.3")
}
  1. Set your locale using xml or programmatically
<com.jop.calendar.CalendarView
    android:id="@+id/calendar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:locale="id-ID"/>
binding.apply {
    calendar.setLocale(Locale("id", "ID"))
}
  1. You can customize the appearance of the buttons, from the background, stroke, icon color, and button shape using xml or programmatically.
<com.jop.calendar.CalendarView
    android:id="@+id/calendar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:locale="id-ID"
    app:buttonStrokeColor="@color/green"
    app:buttonBackgroundColor="@color/greenAccent"
    app:buttonIconColor="@color/green"
    app:isCircleButton="false"/>
binding.apply {
    calendar.setButtonStrokeColor(ColorStateList.valueOf(resources.getColor(R.color.green)))
    calendar.setButtonBackgroundColor(ColorStateList.valueOf(resources.getColor(R.color.greenAccent)))
    calendar.setButtonIconColor(ColorStateList.valueOf(resources.getColor(R.color.green)))
    calendar.setIsCircleButton(false)
}
  1. You can set the weekend color using xml or programmatically.
<com.jop.calendar.CalendarView
    android:id="@+id/calendar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:locale="id-ID"
    app:textWeekEndColor="@color/grey"/>
  1. Callback function when clicked on "selected date"
 binding.apply {
    calendar.setCalenderViewListener(object : CalendarView.CalendarViewListener{
        override fun onSelectedDate(date: Date) {
            TODO("Not yet implemented")
        }
    })
}

About

Libary Custom Calendar View

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages