Need help with date-picker?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

afollestad
147 Stars 20 Forks Apache License 2.0 123 Commits 5 Opened issues

Description

đź“… Custom responsive date picker widget for Android, written in Kotlin.

Services available

!
?

Need anything else?

Contributors list

# 584
Java
Android
Kotlin
android...
118 commits
# 71,737
Java
cron-jo...
Android
Kotlin
3 commits
# 756,405
Kotlin
Android
1 commit
# 121,063
Android
shuffle
Kotlin
kotlin-...
1 commit

Date Picker

Maven Central Android CI Codacy Badge License


Gradle Dependency

dependencies {
  ...
  implementation 'com.afollestad:date-picker:0.6.1'
}

Why?

Android includes a stock

DatePicker
in its framework, however this widget is very stubborn. It does not adapt to different view widths, making it difficult to use in modern UI. This library solves for that by creating a custom implementation, written completely in Kotlin.

Basics

It's simple, just add a

DatePicker
to your layout (with the fully qualified package name):

There are a few basic getters and setters:

val datePicker: DatePicker = // ...

val selectedDate: Calendar? = datePicker.getDate()

datePicker.setDate( year = 2019, month = Calendar.JUNE, selectedDate = 17 ) datePicker.setDate(Calendar.getInstance())


Styling

You can configure basic theme properties from your layout:


(Note that in order for datepickerselection_vibrates=true to have an effect, your app needs to declare the

VIBRATE
permission in its manifest.)


Callback

val datePicker: DatePicker = // ...

datePicker.addOnDateChanged { previousDate, newDate-> // this library provides convenience extensions to Calendar like month, year, and dayOfMonth too. }

// Removes all callbacks you've added previously with addOnDateChanged(...) datePicker.clearOnDateChanged()


Min and Max Dates

val datePicker: DatePicker = // ...

val minDate = datePicker.getMinDate() datePicker.setMinDate( year = 2019, month = Calendar.JUNE, date = 17 ) datePicker.setMinDate(Calendar.getInstance())

val maxDate = datePicker.getMaxDate() datePicker.setMaxDate( year = 2019, month = Calendar.JUNE, date = 20 ) datePicker.setMaxDate(Calendar.getInstance())

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.