在深入了解AOSP主题和样式xml文件以及大量的Google搜索之后,我取得了一些进展。我现在能够设计大部分(!)的东西。
所以这是一个部分答案,并不是所有的方式。但这里有多远我得到:
你可以看到,我现在可以到主题标题,未选择的时间部分(在这种情况下分钟),圆,数字(!)在那个圆圈和'手'(或选择器)中。哦,按钮也是样式的。
让我解释一下我是如何运作的:首先,重要的是你不能直接从你应用程序的主题或从(alert)对话主题/风格中覆盖东西。可以这么说,你必须从一个到另一个。
实施例:
的AndroidManifest.xml:用于应用和/或活性设置自定义主题
<activity>
android:theme="@style/Theme.MyTheme"
</activity>
值-V21/styles.xml:(其中自定义主题所在的):设置时间PickerDialogTheme
<style name="Theme.MyTheme" parent="@style/Theme.AppCompat.Light">
<item name="android:timePickerDialogTheme">@style/TimePickerDialogTheme</item>
</style>
然后在下面,定义timePickerDialo gTheme并设置timePickerStyle:
<style name="TimePickerDialogTheme" parent="@style/Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#ff2d6073</item> <!-- colorAccent here seems to work just fine? -->
<item name="android:timePickerStyle">@style/TimePickerDialogStyle</item>
</style>
现在你可以定义大多数的造型在这里..
<style name="TimePickerDialogStyle" parent="@android:style/Widget.Material.Light.TimePicker">
<item name="colorAccent">#ff2d6073</item> <!-- colorAccent here seems to work just fine? -->
<item name="android:timePickerMode">clock</item>
<item name="android:headerBackground">#ff2d6073</item>
<item name="android:headerTimeTextAppearance">@style/TextAppearance.TimePickerDialogStyle.TimeLabel</item> <!-- TimePicker Time *TextAppearance* -->
<item name="android:numbersTextColor">#ff000000</item>
<item name="android:numbersSelectorColor">#ff2d6073</item>
<item name="android:numbersBackgroundColor">#ffdddddd</item>
</style>
在上面的重要行是:
<item name="android:headerTimeTextAppearance">@style/TextAppearance.TimePickerDialogStyle.TimeLabel</item>
因为如果你想风格的标题,你需要定义headerTimeTextAppearance文本(当然,时间,实际上):
<style name="TextAppearance.TimePickerDialogStyle.TimeLabel" parent="@android:style/TextAppearance.Material">
<item name="android:textSize">60sp</item> <!-- from -->
<item name="android:textColor">#ffD0D102</item>
</style>
现在,如果你看看Widget.Material.TimePicker in AOSP styles.xml(ctrl-f'timepicker',直到你找到它),你会注意到你应该可以修改的一堆其他属性:
headerTimeTextAppearance headerAmPmTextAppearance headerSelectedTextColor headerBackground numbersTextColor numbersBackgroundColor amPmTextColor amPmBackgroundColor amPmSelectedBackgroundColor numbersSelectorColor
大部分工作(只要你在前面加上 '机器人:' 他们每个人的),但我不能得到'headerSelectedTextColor'工作。我收到了一个编译错误,说“不能匹配属性bla bla”。另外,如果你看看我上面的例子,我硬编码了'headerTimeTextAppearance'属性的textSize,因为'@dimen/timepicker_ampm_label_size'值抛出错误。
总之:上面列出了大部分内容,以及如何让它们工作。但并非所有人都清楚。所以我仍然可以看到完整的文档/指南:)
'安卓headerBackground'工作。我无法使'android:numbersTextColor','android:numbersBackgroundColor'工作。 N.B .:'?colorControlActivated'(从'?colorAccent'继承)实际上是突出显示的。 –
谢谢:)我已经取得了一些进展,但在我发布之前需要做一些测试和清理。原来你必须重写主题,然后是样式和(如果你想)headerTextAppearance。 – REJH