A custom horizontally scrolling date picker for Android.
## 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.
Install by adding the library to your module's build.gradle
file.
compile 'com.github.gastricspark:scrolldatepicker:0.0.1'
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.
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);
You can define some attributes to style the ScrollDatePicker
;
baseColor
the default color of the selectorbaseTextColor
the default color of the views textselectedColor
the selected color of the selectorselectedTextColor
the selected text color of the selectorshowTitle
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 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
}
}
});
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.