Android TimePicker 在横向模式下显示不佳 [英] Android TimePicker not displayed well on landscape mode

查看:41
本文介绍了Android TimePicker 在横向模式下显示不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个面向 API 23 的应用,最低 API 为 16.我面临的问题是 TimePicker 显示在 AlertDialog 中.在 Nexus 5 API <=22 上启动应用程序时,显示在纵向模式和横向模式下看起来不错.但是,在 Nexus 5 API 23 上启动应用程序时,横向模式无法正确显示 TimePicker 小部件,它仅显示其背景颜色.

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.

在 Nexus 5 API 23(横向)上:横向模式下的 TimePicker (API 23)

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

推荐答案

您必须从时间选择器对话框中删除设置标题,然后您将在 Nexus 5 中看到时间选择器对话框.此问题已发布在 google 论坛上,请参阅以下链接:

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/问题/详细信息?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();

这篇关于Android TimePicker 在横向模式下显示不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆