Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TimePicker not displayed well on landscape mode

I'm currently building an app targeting API 23, with a minimum API 16. I'm facing an issue where a TimePicker is displayed within an AlertDialog. The display looks fine on Portrait mode and on Landscape mode when launching the app on Nexus 5 API <=22. However, when launching the app on a Nexus 5 API 23, the landscape mode does not correctly display the TimePicker widget, it displays only its background colors.

  • On Nexus 5 API 23 (Portrait): TimePicker on Portrait mode (API 23)

  • On Nexus 5 API 23 (Landscape): TimePicker on Landscape mode (API 23)

like image 853
Anouar Avatar asked Feb 08 '23 17:02

Anouar


1 Answers

You have to remove set title from time picker dialogue after that you will see time picker dialogue in Nexus 5. This issue is posted on google forum see below link :

https://code.google.com/p/android/issues/detail?id=201766

 TimePickerDialog mTimePicker;

        String[] time = txtTimeWriteOut.getText().toString().trim().split(":");
        int hour = Integer.parseInt(time[0]);
        int minute = Integer.parseInt(time[1]);

        mTimePicker = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
            @Override
            public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {

                txtTimeWriteOut.setText(TimeUtils.getDoubleDigits(selectedHour) + ":" + TimeUtils.getDoubleDigits(selectedMinute));

                passTimeOut = currentDate + TimeUtils.getDoubleDigits(selectedHour) + TimeUtils.getDoubleDigits(selectedMinute) + "00";

            }
        }, hour, minute, true);

//        mTimePicker.setTitle("Select Time");
        mTimePicker.show();
like image 152
Darshan Mistry Avatar answered Feb 10 '23 23:02

Darshan Mistry