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
)
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 {
overridefunonDayClick(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")
}
overridefunonDayLongClick(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")
}
overridefunonBackClick(view:View?) {
Log.e("TEST", "onBackClick")
dialog?.dismiss()
}
overridefunonMonthClick(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
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.
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.
Read this in other languages: English, δΈζ. ClockSlider A custom clock view with a circular slider. Supported Android Versions Android 4.0 Jelly Bean(A