- 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" ) }
}
}
- Step two Add the dependency:
dependencies {
implementation("com.github.JOOctp:Custom-Calendar:1.0.3")
}
- 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"))
}
- 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)
}
- 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"/>
- Callback function when clicked on "selected date"
binding.apply {
calendar.setCalenderViewListener(object : CalendarView.CalendarViewListener{
override fun onSelectedDate(date: Date) {
TODO("Not yet implemented")
}
})
}