i have used range date picker from google material with this library
implementation \'com.google.android.material:material:1.2.0-alpha02\'
While the posted answer totally work there seems to be no need to set the materialCalendarTheme
globally - you can just set it to via the MaterialDatePicker.Builder
and setTheme(int themeResId)
method. Following an example how they do it in the Material Design Catalog App.
val datePicker = MaterialDatePicker.Builder.dateRangePicker().apply {
context?.resolveOrNull(R.attr.materialCalendarTheme)?.let {
setTheme(it)
}
setCalendarConstraints(getConstraints())
}.build()
// ...
resolveOrThrow helper method:
fun Context.resolveOrNull(@AttrRes attributeResId: Int): Int? {
val typedValue = TypedValue()
if (theme.resolveAttribute(attributeResId, typedValue, true)) {
return typedValue.data
}
return null
}
This way you DatePicker dialog won't be full screen but a regular dialog.