更改TimePickerDialog的主题以使用AppTheme [英] Change theme of TimePickerDialog to use AppTheme

查看:226
本文介绍了更改TimePickerDialog的主题以使用AppTheme的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用}

我看到这样的对话框:

我想更改TimePickerDialog的主题以与AppTheme一起使用,该主题扩展了AppCompat主题.当我确实按照某些人的指示使用其他构造函数时,主题有效,但是Dialog变为全屏显示.我为此使用的代码是:

I want to change the theme of the TimePickerDialog to go with the AppTheme which extends an AppCompat theme. When i do use the other constructor as told by some, the theme works, but the Dialog goes fullscreen. The code i used for that was:

// Create a new instance of TimePickerDialog and return it
        return new TimePickerDialog(getActivity(), R.style.AppTheme, this, hour, minute,
                DateFormat.is24HourFormat(getActivity()));

我明白了:

我该如何处理? -我希望Dialog保持不变,但仅更改强调色.谢谢!

How do i go about this? - I want the Dialog to remain the same, but change only the accent colors. Thanks!

推荐答案

您必须将Theme.AppCompat.Light.Dialog用作Parent Theme

您需要在styles.xml中定义Dialog主题.

 <style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">@color/purple</item>
        <item name="colorControlNormal">@color/orange</item>
 </style>

然后像这样使用它:

// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), R.style.DialogTheme, this, hour, minute,
DateFormat.is24HourFormat(getActivity()));

希望对您有帮助.

这篇关于更改TimePickerDialog的主题以使用AppTheme的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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