How to highlight dates in Android datepicker like is on the picture below? On the internet, I founded few solutions but they don't use "original" Android datepicker. Is there some solution where I can edit Android datepicker, that I am already using?
The official DatePicker
Android Component, does not support this feature, that's why everyone is creating it's custom view or using a library to do so.
As @ADM said, there's also the MaterialDatePicker
which contains more functionality than the old one, you can check this material design post to get an idea of what you can do.
And for more information MaterialDatePicker
documentation.
To disable dates you should use MaterialDatePicker - CalendarConstraints.DateValidator
, where you can set the dates you want to disable or enable. You don't have to create a custom class in this case but you should create your own implementation of this, you should override
the isValid(long)
method and there you choose the days you want to show as enabled or disabled.
An example of the code you should write is written on this answer : https://stackoverflow.com/a/61147318/4385913
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With