android - 更改 DatePicker 标题文本颜色

标签 android datepicker android-styles datepickerdialog

我有一个在 Lollipop 上显示标题的日期选择器,它看起来像这样 Datepicker

我想将标题中大日期的颜色从黑色更改为白色,或者完全删除标题,我不在乎哪个。我试过更改 textColorPrimarytextColortitleTextColor 但没有效果。

最佳答案

好吧,我不知道您的日期选择器主题的父级 主题是什么。假设您的日期选择器有一个自定义主题,如下所示,

 <style name="yourCustomStyle" parent="Theme.AppCompat.Light">

现在 Ctrl + 单击 Theme.AppCompat.Light 这会引导您进入新的方式 ;) 在那里您可以找到您想要的东西在这里寻找意义您的问题仅与标题文本有关,但您可能希望更改另一种 View 颜色,因此这是您需要查看的地方。

作为答案创建一个自定义主题,如下所示,并使用您喜欢的颜色添加此属性

android:textColorPrimaryInverse

应该能帮到你。

   <style name="yourCustomStyle" parent="Theme.AppCompat.Light">
        <item name="colorAccent">@color/blue</item>
        <item name="android:textColorPrimaryInverse">@color/yellow</item>
        .. other
    </style>

请随意使用您自己的颜色和代码(我从 this 复制代码),它会完成工作!

new DatePickerDialog(MainActivity.this, R.style.yourCustomStyle, new DatePickerDialog.OnDateSetListener() {
    @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
      
    }
}, 2015, 02, 26).show();

enter image description here enter image description here

图片:android:textColorPrimaryInverse with Theme.AppCompat.Dialog

关于android - 更改 DatePicker 标题文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42367430/

相关文章:

Android 绘图库 - achartengine 还是 Androidplot?

android - Handlers 与 Threads 有任何真正的性能影响吗?

javascript - Angular 4 日期选择器语言环境无法正常工作

jquery - JavaScript : jQuery Datepicker - simple highlighting of specific days, 谁能帮忙? (来源内)

Android Theme 样式文件合并

Android 删除操作栏

java - 如何修复此未绑定(bind)前缀错误?不知道我错过了什么

安卓 ICS : Remove blue divider in ActionBar?

Jquery 日期选择器按钮随着本地化消失

android - AppCompatActivity 的 TextView 颜色始终为白色