Coder Social home page Coder Social logo

gregkorossy / datetimepicker Goto Github PK

View Code? Open in Web Editor NEW
73.0 2.0 17.0 816 KB

Material themed DateTimePickers from the Android framework for all API levels (API 14+)

License: Apache License 2.0

Java 100.00%
android material-design datepickerdialog timepickerdialog

datetimepicker's Introduction

Material DatePicker and TimePicker dialogs from the Android framework package with AndroidX

This project is ported from the Android framework. In order to make the pickers material themed on older devices (pre-Lollipop), the appcompat library is used for base theming and vector drawable handling. The widgets always use the custom layouts, this is a complete replacement for the framework pickers. This also means that they have the same look-and-feel on all API levels.

Maven Central

Donation

If you would like to support me, you may donate some small amount via PayPal.

Buy me a coffee


Setup

Add this single line to your gradle file:

implementation 'com.takisoft.datetimepicker:datetimepicker:1.0.3'

And use one of the Theme.AppCompat themes (or a custom one based on that) as your Activity's theme.

Now you can use the following material themed picker dialogs:

  • DatePickerDialog (from com.takisoft.datetimepicker.DatePickerDialog)
  • TimePickerDialog (from com.takisoft.datetimepicker.TimePickerDialog)

Additionally you could technically use DatePicker and TimePicker from the com.takisoft.datetimepicker.widget package inside a layout as an inline view, however, they do not support scrolling containers, so it's recommended to stick with the dialogs instead.

This lib now uses AndroidX. If you don't want / can't migrate to AndroidX yet, check out the old-support branch.


Customization

You can override the following attributes in your theme (check out the default styles for details):

Attribute Description Default (dark) / (light)
datePickerStyle The DatePicker's style Widget.Material.DatePicker / Widget.Material.Light.DatePicker
datePickerDialogTheme The DatePickerDialog's style ThemeOverlay.Material.Dialog.DatePicker
timePickerStyle The TimePicker's style Widget.Material.TimePicker / Widget.Material.Light.TimePicker
timePickerDialogTheme The TimePickerDialog's style ThemeOverlay.Material.Dialog.TimePicker
numberPickerStyle The NumberPicker's style which is going to be used if there's not enough room on the screen for the normal pickers Widget.Material.NumberPicker / Widget.Material.Light.NumberPicker
calendarViewStyle The CalendarView's style Widget.Material.CalendarView / Widget.Material.Light.CalendarView

Watch out not to include the android: prefix before the attribute names if you want to override them as it will not work. These attributes have been (re)defined for the project in order to be able to access the internal details, which means that they do not belong to the android namespace anymore.

Some pictures

API 15 API 26
DatePicker DatePicker
DatePicker DatePicker
DatePicker DatePicker
DatePicker DatePicker

You can see that in landscape the API 15 images show spinners instead of a calendar view. This is because there is not enough room for the calendar, so the spinners are used as fallback.

datetimepicker's People

Contributors

gregkorossy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

datetimepicker's Issues

Can't override colorAccent?

I might be missing some nuance due to using this library, but I couldn't figure out how to override colorAccent.

The reason for this is because I want to change the color of the overall datepicker, without propagating those changes throughout the rest of the app.

Am I missing something or does this truly not work:

    <style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">#FF0000</item>
    </style>

...

    <com.takisoft.datetimepicker.widget.DatePicker
        android:id="@+id/date_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/datepicker"
        />

I also tried setting the style attributes from your readme, with similar results (or a lack of, rather)

An alternative would be to change all the colors of the datepicker manually, but I couldn't figure out the attribute for the selected day indicator, only for the other colored components.

Feedback TimePicker Problem

I am trying to programmatically change the "numbersTextColor" color for "TimePicker", but did not succeed, what am I doing wrong? How should I modify it?

image

DateTimePicker style error

When theme Uses MaterialComponents Instead of AppCompat the Button style error.

tim 20180618222100tim 20180618222103

Style:

    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorSecondary">@color/colorSecondary</item>
    </style>

setMinTime feature request.

Feature request.
I need a feature called setMinTime, through which I can restrict users i.e they can not set the time less then 3:40 AM (for example).

Is this already done? I am not sure.
Please let me know any alternate for this.
Thank you

Select actual Date

How to make to select only future and now dates? (No old like 1972, 2018)

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.