更改TimePickerDialog的主题以使用AppTheme [英] Change theme of TimePickerDialog to use AppTheme
本文介绍了更改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屋!
查看全文