I am using a third party library: SingleDateTimePicker
https://github.com/florent37/SingleDateAndTimePicker
This is a great way to display a dialog at the bottom of the screen of date and time. This is how I am doing it:
new SingleDateAndTimePickerDialog.Builder(getContext())
.displayMinutes(false)
.bottomSheet()
.curved()
.displayListener(new SingleDateAndTimePickerDialog.DisplayListener(){
@Override
public void onDisplayed(SingleDateAndTimePicker picker) {
System.out.println("displayed");
}
})
.title("Select Time")
.listener(new SingleDateAndTimePickerDialog.Listener() {
@Override
public void onDateSelected(Date date) {
System.out.println(date.toString());
...
...
}
})
.display();
My only issue here is that when the picker pops up the back screen does not darken to emphasize the popup (like a dialog fragment). Is there a way to darken the background manually?
I tried to put the above library in a layout of its own and inflate it from a DialogFragment
, however with this approach I am not sure how to call onDateSelected
to get the date
(at the same time, DialogFragment impose certain layout parameters like, the dialog has to be in the middle of the screen and cannot have a width that match_parent
. That is why I don't think that putting this in a Dialog Fragment is the way to go)
Note: the non-picker area is clickable. i.e. when clicked the picker area disappears
This is what I want:
use this will take your application style : https://github.com/Kunzisoft/Android-SwitchDateTimePicker