LazyDatePicker

Additional

Language
Java
Version
N/A
Created
Jul 5, 2018
Updated
Jul 18, 2018
Owner
Lopez Mikhael (lopspower)
Contributor
Lopez Mikhael (lopspower)
1
Activity
Badge
Generate
Download
Source code
APK file

Promotion

LazyDatePicker



This is an Android project to offer an alternative to the native Android Date Picker.

USAGE

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.0.0'

XML

<com.mikhaellopez.lazydatepicker.LazyDatePicker
        android:id="@+id/lazyDatePicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:ldp_text_color="@color/primary"
        app:ldp_hint_color="@color/accent"
        app:ldp_date_format="mm-dd-yyyy" />

You must use the following properties in your XML to change your LazyDatePicker.

Properties:
  • app:ldp_text_color (color) -> default BLACK
  • app:ldp_hint_color (color) -> default GRAY
  • app:ldp_date_format (mm-dd-yyyy or dd-mm-yyyy) -> default mm-dd-yyyy

KOTLIN

lazyDatePicker.setDateFormat(LazyDatePicker.DateFormat.MM_DD_YYYY)
lazyDatePicker.setMinDate(minDate)
lazyDatePicker.setMaxDate(maxDate)

lazyDatePicker.setOnDatePickListener { dateSelected ->
    //...
}

JAVA

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) {
        //...
    }
});

OVERRIDE

You can override day, month & year if you want like this in your strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <string name="ldp_day" tools:override="true">D</string>
    <string name="ldp_month" tools:override="true">M</string>
    <string name="ldp_year" tools:override="true">Y</string>
</resources>

You can also change the design of the picker by changing the dimensions like this in your dimens.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <dimen name="lazy_date_picker_width_case" tools:override="true">12dp</dimen>
    <dimen name="lazy_date_picker_height_focus" tools:override="true">2.5dp</dimen>
    <dimen name="lazy_date_picker_width_margin" tools:override="true">1dp</dimen>
    <dimen name="lazy_date_picker_width_space" tools:override="true">6dp</dimen>
</resources>

LICENCE

LazyDatePicker by Lopez Mikhael is licensed under a Apache License 2.0.