Month Year Picker
Customizable Android library for selecting months and years with theme support.
Creator & Maintainer·1 min readMaintained
Kotlin
Android SDK
Material Design
Android Library
UI Component
Month Year Picker
Since android doesn't have a direct way to do month year picker, here is a customizable library to do so.
Features
- Support Theme Change persisting data
- Selected Date
- Minumum and Maximum dates
Screenshot
Usage/Examples
To start a picker
val monthYearPickerBuilder = MonthYearPicker.Builder(this)
.setTitle("Title")
.setLifeCycleOwner(this)
.setStyle(R.style.ThemeMonthYearPicker)
.setTypeFace(ResourcesCompat.getFont(this, R.font.custom_typeface))
.setLocale(Locale("en", "kw"))
.setMinDate(nextMonths(2))
.setMaxDate(nextMonths(120))
.setSelectedDate(nextMonths(50))
.setShortMonths(true)
.setCancelable(false)
.setCallback { year, month ->
println("Month: ${month + 1}, Year: $year")
}
.setCallbackNatural { year, month ->
println("Month: $month, Year: $year")
}
monthYearPickerBuilder.build().show()To customize the picker style
<item name="backgroundColor">?colorSurface</item>
<item name="titleColor">?colorOnBackground</item>
<item name="dayPickerActive">?colorOnSecondary</item>
<item name="dayPickerInActive">?colorOnBackground</item>
<item name="yearPickerActive">?colorOnSecondary</item>
<item name="yearPickerInActive">?colorOnBackground</item>
<item name="dividerColor">?colorSecondary</item>
<item name="dividerBackgroundColor">?colorSecondary</item>
<item name="negativeTextColor">?colorPrimary</item>
<item name="positiveTextColor">?colorPrimary</item>Installation
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.azikar24:MonthYearPicker:1.0.0'
}