DateTimePicker对话框上的Android Style Theme.Material.Light.Dialog

时间:2015-10-21 09:00:40

标签: android titanium android-alertdialog android-styles

我在我正在构建的Android应用上使用Titanium。虽然该框架是Titanium,但我认为这个答案也适用于原生(在某种程度上)。

我正在尝试设置DatePicker对话框和TimePicker对话框,我已经设法 开始工作。但是我现在处于系绳的尽头,试图让Highlight Circle和OK / Cancel按钮与对话框样式的其余部分相匹配。

我希望这很简单。我附加了两个屏幕截图,我正在寻找的颜色与标题背景颜色相同,而不是目前正确/取消和日期高亮圆圈的青色。

以下是代码:

以下是窗口的主题

     <style name="Theme.DelegateWindow" parent="@style/Theme.AppCompat">
      <item name="windowActionBar">false</item>
      <item name="windowNoTitle">true</item>
      <item name="android:statusBarColor">#1456A5</item>
      <item name="colorControlNormal">#DADAD9</item>
      <item name="colorControlActivated">#DADAD9</item>
      <item name="colorControlHighlight">#DADAD9</item>
      <item name="android:datePickerDialogTheme">@style/MyDatePickerDialogTheme</item>
      <item name="android:timePickerDialogTheme">@style/MyTimePickerDialogTheme</item>
    </style>

这是datePickerDialogTheme和timePickerDialogTheme

    <style name="MyDatePickerDialogTheme" parent="android:Theme.Material.Light.Dialog">
        <item name="colorAccent">@color/primary</item>
        <item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
    </style>

    <style name="MyTimePickerDialogTheme" parent="android:Theme.Material.Light.Dialog">
        <item name="colorAccent">@color/primary</item>
        <item name="android:timePickerStyle">@style/MyTimePickerStyle</item>
    </style>

最后是Styles

    <style name="MyDatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker">
        <item name="android:headerBackground">@color/primary</item>
        <item name="android:calendarTextColor">@color/DarkGrey</item>
        <item name="android:dayOfWeekBackground">@color/primaryDark</item>
        <item name="android:yearListSelectorColor">@color/primary</item>
    </style>

    <style name="MyTimePickerStyle" parent="@android:style/Widget.Material.Light.TimePicker">
        <item name="android:headerBackground">@color/primary</item>
        <item name="android:calendarTextColor">@color/DarkGrey</item>
        <item name="android:dayOfWeekBackground">@color/primaryDark</item>
        <item name="android:yearListSelectorColor">@color/primary</item>
    </style>

Image 1 Date Picker Image 2 Time Picker

1 个答案:

答案 0 :(得分:1)

我明白了。

我不得不改变:

parent="@android:style/Widget.Material.Light.TimePicker"

Theme.AppCompat.Light.Dialog

所以最后的结果是

    <style name="MyDatePickerDialogTheme" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">@color/primary</item>
        <item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
    </style>

    <style name="MyTimePickerDialogTheme" parent="Theme.AppCompat.Light.Dialog">
        <item name="colorAccent">@color/primary</item>
        <item name="android:timePickerStyle">@style/MyTimePickerStyle</item>
    </style>