3

Using the default DatePicker class from android it was possible to make the datepicker in form of spinner like this:

spinner

But with MaterialDesignSpinner it seems that this feature by default is not implemented, as the only form looks like this:

example

or default textview input.

Did materialdesign remove the spinner feature, or is there a way to implementing it using the MaterialDatePicker?

igodie
  • 497
  • 1
  • 4
  • 16
  • 1
    For reference, here is the feature request on `MaterialDatePicker` for exactly this. https://github.com/material-components/material-components-android/issues/1264 – Richard Le Mesurier Mar 03 '22 at 13:55

1 Answers1

1

I could't find a solution for the MaterialDatePicker, but I want to share my solution anyways, it works for my purpose it might for yours too:

    DatePickerDialog dpd = new DatePickerDialog(this,
            AlertDialog.THEME_HOLO_LIGHT,null, 1960, 1, 1);
    dpd.getDatePicker().setCalendarViewShown(false);
    dpd.show();

This will display the light version of the date picker dialog. You can also use:

AlertDialog.THEME_HOLO_DARK

For a dark dialog theme or:

android.R.style.Theme_Holo_Light_Dialog

For a slightly different dialog itself. Keep in mind to set dpd.getDatePicker().setCalendarViewShown(false); otherwise the regular calendar part of the picker is shown in addition. If you look for more variations see this answer.

user2267367
  • 704
  • 7
  • 19