• Stars
    star
    372
  • Rank 114,858 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LazyDatePicker an alternative to the native Android Date Picker 📅

LazyDatePicker

sample

Platform API Maven Central
Android Weekly Twitter

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

Android app on Google Play

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.1.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 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

KOTLIN

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 ->
    //...
}

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

lazyDatePicker.setOnDateSelectedListener(new LazyDatePicker.OnDateSelectedListener() {
    @Override
    public void onDateSelected(Boolean dateSelected) {
        //...
    }
});

LOCAL DATE

You can used LazyLocalDatePicker instead of LazyDatePicker to have all method with LocalDate instead of Date.

XML:

<com.mikhaellopez.lazydatepicker.LazyLocalDatePicker
    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" />

KOTLIN:

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 ->
    //...
}

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>

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

SUPPORT ❤️

Find this library useful? Support it by joining stargazers for this repository ⭐️
And follow me for my next creations 👍

LICENCE

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

More Repositories

1

CircularImageView

Create circular ImageView in Android in the simplest way possible
Kotlin
1,949
star
2

CircularProgressBar

Create circular ProgressBar in Android ⭕
Kotlin
1,698
star
3

CircularFillableLoaders

Realize a beautiful circular fillable loaders to be used for splashscreen 🌊
Java
1,222
star
4

BestAndroidGists

Find best Android Gist 🔥
890
star
5

RxAnimation

Simple way to animate your views on Android with Rx 🚀
Kotlin
590
star
6

AndroidWebServer

Android Web Server (NanoHttpd)
Java
433
star
7

CleanRxArchitecture

Clean Rx Kotlin Architecture sample on GitHub Api 🚀
Kotlin
387
star
8

RateBottomSheet

To help to promote your android app by prompting users to rate your app in a BottomSheet ⭐️
Kotlin
308
star
9

GradientView

Create gradient view in Android in the simplest way possible 🌈
Kotlin
197
star
10

HFRecyclerView

Add Header and/or Footer in your RecyclerView in the simplest way possible.
Kotlin
170
star
11

CircleView

Create circular view in android (change color, border & shadow) ⚫
Kotlin
165
star
12

Biometric

The easiest way is to use the new version of Biometric under AndroidX 🔒
Kotlin
140
star
13

PokeCardCompose

PokeCard Compose is a demo app 100% write in Compose, Flow and Koin based on MVI Clean Architecture 🐱⚡️
Kotlin
115
star
14

SaveInsta

Example dynamic update of your theme based on a main color
Java
85
star
15

AutoScrollTextView

Sample Android application show how to set auto scroll in text view in android.
Java
51
star
16

FavoriteAndroidLibrary

My Farorite Android Library
49
star
17

MyToast

Custom Toast on Android
Java
39
star
18

DualShot

With DualShot you take two photos with the front and the back camera, and share both of them in a single image.
Java
23
star
19

WebSideMVC

Structure MVC for Web Side in PHP
PHP
1
star