Datepicker is an IOS datepicker widget-like date and time picker library.
The library has many different feature options to customize your widget.
DatePicker datePicker = findViewById(R.id.datepicker);
datePicker.setOffset(3);
datePicker.setTextSize(19);
datePicker.setPickerMode(DatePicker.DAY_ON_FIRST);
datePicker.setMaxDate(/*long time*/);
datePicker.setDate(/*long time*/);
datePicker.setMinDate(/*long time*/);
datePicker.setDataSelectListener(new DatePicker.DataSelectListener() {
@Override
public void onDateSelected(long date, int day, int month, int year) {
}
});
<com.ozcanalasalvar.library.view.datePicker.DatePicker
android:id="@+id/datepicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:offset="3"
app:pickerMode="dayFirst"
app:textSize="19" />
datePickerPopup = new DatePickerPopup.Builder()
.from(/*context*/)
.offset(3)
.pickerMode(DatePicker.MONTH_ON_FIRST)
.textSize(19)
.endDate(/*long time*/)
.currentDate(/*long time*/)
.startDate(/*long time*/)
.listener(new DatePickerPopup.OnDateSelectListener() {
@Override
public void onDateSelected(DatePicker dp, long date, int day, int month, int year) {
}
})
.build();
TimePicker timePicker = findViewById(R.id.timepicker);
timePicker.setOffset(2);
timePicker.setTextSize(19);
timePicker.setHour(/*hour*/);
timePicker.setMinute(/*minute*/);
timePicker.setTimeSelectListener(new TimePicker.TimeSelectListener() {
@Override
public void onTimeSelected(int hour, int minute) {
}
});
<com.ozcanalasalvar.library.view.timePicker.TimePicker
android:id="@+id/timepicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:offset="2"
app:textSize="17" />
timePickerPopup = new TimePickerPopup.Builder()
.from(this)
.offset(3)
.textSize(17)
.setTime(/*hour*/, /*minute*/)
.listener(new TimePickerPopup.OnTimeSelectListener() {
@Override
public void onTimeSelected(TimePicker timePicker, int hour, int minute) {
}
})
.build();
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.OzcanAlasalvar:DatePicker:1.0.4'
}