Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight dates in android datepicker?

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?

Datepicker with highlighted dates

like image 969
Michael A. Avatar asked Oct 18 '25 10:10

Michael A.


1 Answers

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.

Edit

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

like image 148
Skizo-ozᴉʞS Avatar answered Oct 21 '25 00:10

Skizo-ozᴉʞS