我有一个在 Lollipop 上显示标题的日期选择器,它看起来像这样
我想将标题中大日期的颜色从黑色更改为白色,或者完全删除标题,我不在乎哪个。我试过更改 textColorPrimary
、textColor
和 titleTextColor
但没有效果。
最佳答案
好吧,我不知道您的日期选择器主题的父级 主题是什么。假设您的日期选择器有一个自定义主题,如下所示,
<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();
图片:android:textColorPrimaryInverse with Theme.AppCompat.Dialog
关于android - 更改 DatePicker 标题文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42367430/