Restrict Range in Android DatePicker Custom Dialog

后端 未结 3 1466
野的像风
野的像风 2020-12-21 03:08

I have a custom linear layout which has DatePicker and TimePicker widgets in it. This is used as DateTime picker. I want to restrict t

3条回答
  •  情书的邮戳
    2020-12-21 03:30

    For future readers!

    Actually with new android material design components what you want achieve could be achieved using MaterialDatePicker. And dates outside the allowed range is not selectable.


    Steps

    1. Add material dependency to your module's gradle file

    implementation 'com.google.android.material:material:1.1.0-beta01'
    

    2. Change app theme to inherit from a version of material theme.

    ex: