问题描述
我在我的应用程序使用时间选择器对话框。我也用appcompat我给我的应用材料的设计主题。该对话框然而,与默认水鸭口音的颜色保持(我的口音是一个淡蓝色的)。
I am using a time picker dialog in my app. I am also using appcompat to give my app material design theme. The dialog however stays with the default teal accent color (my accent is a light blue).
所以在我的code我尝试设置对话框主题,我自己和它的作品接受它使得全屏
so in my code I tried setting the dialog theme to my own and it works accept it makes it fullscreen
mTimePicker = new TimePickerDialog(ctx, R.style.AppTheme new TimePickerDialog.OnTimeSetListener() {->}, hour, minute, DateFormat.is24HourFormat(context));
没有人知道如何设置TimePickerDialog用我的色彩,而不是默认的显示正确?
does anyone know how to set the TimePickerDialog to show correctly with my colors instead of the default ones?
推荐答案
这可以很容易地从XML实现(5.0+只)
This can be easily achieved from xml (5.0+ only)
V21 /的themes.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme"
parent="MyTheme.Base">
<item name="android:dialogTheme">@style/Theme.Dialog</item> <!-- TimePicker dialog -->
<item name="android:alertDialogTheme">@style/Theme.Dialog</item> <!-- Alert dialog -->
</style>
<style name="Theme.Dialog"
parent="android:Theme.Material.Light.Dialog">
<item name="android:colorAccent">@color/...</item>
<item name="android:colorPrimary">@color/...</item>
<item name="android:colorPrimaryDark">@color/...</item>
</style>
</resources>
修改
请注意,由于Android的支持库22.1.0的有一个新的 AppCompatDialog
可用!的
Edit
Please note that as of Android Support Library 22.1.0 there is a new AppCompatDialog
available! http://android-developers.blogspot.de/2015/04/android-support-library-221.html
这篇关于Android的TimePickerDialog材料设计颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!