DatePickerDialog标头背景色 [英] DatePickerDialog header background color

查看:286
本文介绍了DatePickerDialog标头背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为DatePickerDialog背景设置了一种样式,它在Nexus 5(棉花糖)上的显示方式有所不同:

I've setup a style for a DatePickerDialog background, and it shows up differently on Nexus 5 (Marshmallow):

我使用的样式是:

<style name="datepicker">
    <item name="android:background">@color/android:white</item>
    <item name="android:textColorPrimaryInverse">@color/android:black</item>
    <item name="android:textColorPrimary">@color/android:black</item>
    <item name="android:textColorSecondary">@color/colorAccent</item>
    <item name="android:textColorSecondaryInverse">@color/colorAccent</item>
    <item name="android:textColorTertiary">@color/android:black</item>
</style>

(colorAccent是金)

最上面的年份应该由textColorSecondary控制,但是现在显示为黑色.标头的背景是灰色,我想要白色.棉花糖这些物品的名字是什么?

The year at the top is supposed to be controlled by textColorSecondary, but now it's showing up as black. And the background of the header is grey, which I'd like white. What are the names of these items for Marshmallow?

推荐答案

您可以使用此styletheme配置更改文本和标题颜色.但是,我认为它并不比默认对话框选择器漂亮.

You can use this style and theme config for change the text and header color. However, I think it is not more beautiful than default dialog picker.

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    ...
    <item name="android:datePickerDialogTheme">@style/MyDatePickerDialogTheme</item>

</style>

<style name="MyDatePickerDialogTheme" parent="android:Theme.Material.Light.Dialog">
    <item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
    <item name="android:textColorPrimaryInverse">#000</item> <!-- header date, month color && calendar text highlight color -->
    <item name="android:textColorSecondaryInverse">#000</item> <!-- header year color -->

    <item name="android:colorAccent">#B09A60</item> <!-- button color -->
</style>

<style name="MyDatePickerStyle" parent="@android:style/Widget.Material.Light.DatePicker">
    <item name="android:headerBackground">#fff</item> <!-- header background color -->
</style>

经过API 22、23、25测试

Tested on API 22, 23, 25

这篇关于DatePickerDialog标头背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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