Android TimePicker not showing in landscape mode

I am currently creating an API 23 targeting application with a minimum API of 16. I ran into a problem when TimePicker is displayed in AlertDialog. The display looks great in the Portrait mode and in the Landscape mode when the application is launched on the Nexus 5 API <= 22. However, when the application starts in the Nexus 5 API 23, the TimePicker widget does not display correctly in landscape mode, it only displays its background colors.

+4
source share
3 answers

You need to remove the specified title from the time selection dialog, after which you will see the time selection dialog in Nexus 5. This problem is published on the google forum, see the link below:

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();
+6
source

I have this problem. This help is for me:

timePicker.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+1
source

1. :

, onCreateDialog():

, TimePickerDialog , setTitle(null) , , :

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

    /* ... */

    Dialog dialogFragment = new TimePickerDialog(/* ... */);
    dialogFragment.setTitle(null);
    return dialogFragment;
}

, Android 5.0.2 (Lollipop). .

Android 6.0. .

2. , :

TimePickerDialog. . , null.

, setupTitle() -private class AlertController. AlertControler AlertDialog -.

+1

Source: https://habr.com/ru/post/1629465/


All Articles