Material day selector
Builder inspired by the day in the integrated Android clock application.
Normal use | Localised uses | Operation in dark mode |
---|---|---|
![]() |
![]() |
![]() |
Characteristics
- Customizable themes
- ✅ API/Friendly Hooks
- Fully localized
- Supports dark mode
What’s new: Version 0.7.3 – improved configuration + bug fixes
- Updated MaterialDayPicker to target API 30 and updated are AndroidX dependencies
Goes from 0.7.2
Bugfixes
- Fixed a bug in using the Android 3.6.1 notation plugin that caused a forum error because the selectionMode attribute could not be found.
Goes from 0.7.1
Bugfixes
- Correct an issue where the selected days blink when calling setSelectedDays.
Increases from 0.7.0 to
Configuration improvements
- You can now enable/disable days from the moment you select them using the enableDay/disableDay methods. Read more about this below.
- You can now define the selection mode via xml with the attribute app:selectionMode.
Download the latest version by adding the following to your project’s build.gradle file:
Dependencies {
Implementation ca.antonious:materialdaypicker:0.7.3
}.
Use of MaterialDayPicker in your application
You can simply start a view on your existing xml file:
You can retrieve the currently selected days by using :
val selectedDays = materialDayPicker.selectedDays
// returns [MaterialDayPicker.Weekday.TUESDAY, MaterialDayPicker.Weekday.FRIDAY].
Allows you to define the selected days:
val daysToSelect = list of selected days (MaterialDayPicker.Weekday.TUESDAY, MaterialDayPicker.Weekday.FRIDAY)
materialDayPicker.netSelected days(daysToSelected)
If you only want to allow one day at a time, you can do that:
materialDayPicker.selectionMode = Simple selectionMode.create()
This can also be defined via xml with the SelectionMode attribute :
You can activate/deactivate the days in the following way. Please note that a deactivation cannot be undone on the day it is selected:
materialDayPicker.disableDay (MaterialDayPicker.Weekday.Monday)
materialDayPicker.setDayEnable (MaterialDayPicker.Weekday.Monday, isEnabled = false)
If you want to listen when the choice of the day changes, you can use this:
materialDayPicker.setDaySelectionChangedListener { selectedDays ->
// Change the selection of the handle
}
If you want to know when a particular day has been selected/refused, you can use :
materialDayPicker.setDayPressListener {Weekday, selected ->
// Selection button
}
Configuring MaterialDayPicker for your application
You can redefine these colors to change the appearance of MaterialDayPicker. You can also update these values in your Nightcolor resource directory to update the appearance of MaterialDayPicker in dark mode:
@color/colorPrimaryDark @color/colorPrimary @android:color/white #FAFAFA @android:color/black
#43444E @Color/TagSelectedText color @Color/TagDisabled @Android:color/darker_grey
If you do not want to use the device’s current location, you can ignore it by doing so:
materialDayPicker.locale = locale.ENGLISH // or another locale.
GitHub
Related Tags:
s&a concrete new york,x.l.o. concrete