LazyDatePicker 是 Android 原生日期选择器的替代方案
This is an Android project to offer an alternative to the native Android Date Picker.
To make a lazy date picker add LazyDatePicker in your layout XML and add LazyDatePicker library in your project or you can also grab it via Gradle:
implementation 'com.mikhaellopez:lazydatepicker:1.1.0'You must use the following properties in your XML to change your LazyDatePicker.
| Properties | Type | Default |
|---|---|---|
app:ldp_text_color |
color | BLACK |
app:ldp_hint_color |
color | GRAY |
app:ldp_date_format |
mm-dd-yyyy or dd-mm-yyyy | mm-dd-yyyy |
app:ldp_show_full_date |
boolean | true |
lazyDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY)
lazyDatePicker.setMinDate(minDate)
lazyDatePicker.setMaxDate(maxDate)
// The date when is selected
lazyDatePicker.setOnDatePickListener { dateSelected ->
//...
}
// True or false when date is selected
lazyDatePicker.setOnDateSelectedListener { dateSelected ->
//...
}LazyDatePicker lazyDatePicker = findViewById(R.id.lazyDatePicker);
lazyDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY);
lazyDatePicker.setMinDate(minDate);
lazyDatePicker.setMaxDate(maxDate);
lazyDatePicker.setOnDatePickListener(new LazyDatePicker.OnDatePickListener() {
@Override
public void onDatePick(Date dateSelected) {
//...
}
});
lazyDatePicker.setOnDateSelectedListener(new LazyDatePicker.OnDateSelectedListener() {
@Override
public void onDateSelected(Boolean dateSelected) {
//...
}
});You can used LazyLocalDatePicker instead of LazyDatePicker to have all method with LocalDate instead of Date.
lazyLocalDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY)
lazyLocalDatePicker.setMinLocalDate(minDate)
lazyLocalDatePicker.setMaxLocalDate(maxDate)
// The localdate when is selected
lazyLocalDatePicker.setOnLocalDatePickListener { localDateSelected ->
//...
}
// True or false when date is selected
lazyLocalDatePicker.setOnLocalDateSelectedListener { dateSelected ->
//...
}You can override day, month & year if you want like this in your strings.xml:
D
M
Y
You can also change the design of the picker by changing the dimensions like this in your dimens.xml:
12dp
2.5dp
1dp
6dp
And to finish you can also completely redefine the layout by keeping the same name layout_lazy_date_picker.xml and keep all the ids. You can find the default one here: layout_lazy_date_picker.xml
Find this library useful? Support it by joining stargazers for this repository ⭐️
And follow me for my next creations
LazyDatePicker by Lopez Mikhael is licensed under a Apache License 2.0.
暂无开放 Issues,或尚未同步最近议题。