Git Product home page Git Product logo

spinnerdatepicker's Introduction

API Android Arsenal Release

Spinner DatePicker

Summary

The old "spinner" style DatePicker for newer devices.

ScreenShot

Motivation

The default Material Design DatePicker has poor usability for choosing a date of birth. It seems it is hard for users to find the "year" button and they will often simply swipe left or right through the months in order to find their date of birth.

MaterialDesign

The previous Holo DatePicker with sliding NumberPickers is much more suitable for this use case however it is no longer available for Marshmallow devices and up.

This library is heavily based on the latest Android Open Source Project DatePicker (source code here) with the addition of being able to style the NumberPickers (the dials/spinners in the DatePicker).

Adding styles

The DatePicker is the simple aggregation of three NumberPickers. You can style the DatePicker easily with a NumberPicker style:

<style name="NumberPickerStyle">
    <item name="android:textSize">22dp</item>
    <item name="android:textColorPrimary">@color/colorAccent</item>
    <item name="android:colorControlNormal" tools:targetApi="lollipop">@color/colorAccent</item>
</style>

where colorControlNormal is the color of the horizontal bars (dividers) in the NumberPicker. See this StackOverflow question

And then:

    new SpinnerDatePickerDialogBuilder()
            .context(MainActivity.this)
            .callback(MainActivity.this)
            .spinnerTheme(spinnerTheme)
            .defaultDate(2017, 0, 1)
            .maxDate(2000, 0, 1)
            .minDate(2020, 0, 1)
            .build()
            .show();

The example project should make it clear - get it by cloning the repo.

Note that full support is only for API >= 18. API < 18 you'll get the DatePicker but there is no easy way to style it correctly.

Usage in a project

Add the following to your project level build.gradle:

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
	   }
}

Add this to your app level build.gradle:

dependencies {
    compile 'com.github.drawers:SpinnerDatePicker:1.0.4'
}

Philosophy

The aim of this project is to produce a lightweight and robust DatePicker with an API similar to that of the standard Android DatePicker. Hence the library has no external dependencies and no fancy features. Espresso automated UI testing is performed on the sample project using Firebase test lab.

Contributing

Please open an issue first before making a pull request. Pull requests should be accompanied by tests if possible.

License

Copyright 2017 David Rawson

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

spinnerdatepicker's People

Contributors

drawers avatar mwolfson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.