-1

In android application, I have used TimePickerDialog and DatePickerDialog. I want to develop this app in all different screen sizes.

The problem is, this dialog size is the same on all screen sizes. Dialog does not adjust its size as the size of the screen changes. So, on a smaller screen, the content of the dialog is cut off.

How can I adjust this dialog?

below is output I am getting in different size device. I even can't able to scroll in this dialog

App output1

App output2

Code of DatePickerdialog:

 DatePickerDialog datePicker;

 editText_date.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            datePicker = new DatePickerDialog(mActivity,new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int y, int m, int d) {               
                 //other code here
                }
            },yy,mm,dd);

         //allow only future dates
            datePicker.getDatePicker().setMinDate(System.currentTimeMillis());
            datePicker.getDatePicker().setMaxDate(maxDate.getTimeInMillis());
            datePicker.show();
        }
    });

1 Answers1

0

you can use these code block. if you will receive error you can write.

    private void dialogDatePickerLight() {
    Calendar cur_calender = Calendar.getInstance();
    DatePickerDialog datePicker = DatePickerDialog.newInstance(
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    long date_ship_millis = calendar.getTimeInMillis();

                }
            },

            cur_calender.get(Calendar.YEAR),
            cur_calender.get(Calendar.MONTH),
            cur_calender.get(Calendar.DAY_OF_MONTH)
    );

    datePicker.setThemeDark(false);
    datePicker.setAccentColor(getResources().getColor(R.color.cyan_800_overlay));
    datePicker.setMinDate(cur_calender);
    datePicker.show(getFragmentManager(), "Title is here");

}
Yunus Karakaya
  • 531
  • 3
  • 16