nazy61 / ScrollDatePicker

A Custom Horizontal Scroll DatePicker for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scroll Date Picker

A custom horizontally scrolling date picker for Android.

On Maven Central: Version 0.0.1 Platform: Android License: MIT


Screenshots

DayScrollDatePicker MonthScrollDatePicker

## Features - Easy to use views to implement horizontal scrolling date pickers - Custom Atributes allow the user to set the style. - Ability to set start and end dates. - Simple way to implement date input.

Installation

Install by adding the library to your module's build.gradle file.

compile 'com.github.gastricspark:scrolldatepicker:0.0.1'

Usage

To include a ScrollDatePicker within your application all you have to do is implement it in your layout and then get the value on your activity.

Set Up

Inlcude either MonthScrollDatePicker or DayScrollDatePicker within your layout.

<com.harrywhewell.scrolldatepicker.DayScrollDatePicker
   android:id="@+id/day_date_picker"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
 />

Then just treat it like any other view, find it by id.
mPicker = (DayScrollDatePicker) findViewById(R.id.day_picker);
Then once you have an object of it you can set the start date (local date by default) and the end date (infinate by default ).
mPicker.setStartDate(10, 10, 2010);
mPicker.setEndDate(11, 11, 2011);

Attributes

You can define some attributes to style the ScrollDatePicker ;

  • baseColor the default color of the selector
  • baseTextColor the default color of the views text
  • selectedColor the selected color of the selector
  • selectedTextColor the selected text color of the selector
  • showTitle if the title should be shown e.g. '2016' (true by defualt)
  • showFullDate if the full date should be shown e.g. '28 Feburary 2016' (true by default)

Getting Date

Getting date from the view is really easy, all you have to do is call getSelectedDate and then implement the OnDateSelectedListener.

 mPicker.getSelectedDate(new OnDateSelectedListener() {
   @Override
     public void onDateSelected(@Nullable Date date) {
       if(date != null){
         // do something with selected date
       }
     }
   });

Sample App

There is a sample application included so that you can see how to implement the Scroll Date Pickers, as well as definie their attributes and get their values.

About

A Custom Horizontal Scroll DatePicker for Android


Languages

Language:Java 100.0%