更改DatePicker标题文本颜色 [英] Change DatePicker header text color

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

问题描述

我有一个datepicker在Lollipop上显示标题,看起来像这样



我想要将标题中的大日期的颜色从黑色更改为白色,或者完全删除标题,我不在乎哪个。我尝试更改 textColorPrimary textColor titleTextColor 它没有任何效果。

解决方案

我不知道你所拥有的主题是什么您的日期选择器主题。假设您的日期选择器的自定义主题如下所示,

 < style name =yourCustomStyleparent =Theme .AppCompat.Light> 

现在 Ctrl +点击 Theme.AppCompat.Light ,这将引导您采用新的方式;)您可以在哪里找到所需的内容,您的问题仅在于您的主题文字,但您可能希望更改另一种视图颜色,这就是您需要看的地方。



而且由于回答创建了如下所示的自定义主题,并使用您喜欢的颜色添加此属性



android:textColorPrimaryInverse



应该为你做点事。

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

随意使用自己的颜色和代码(我从



图片:android:textColorPrimary与Theme.AppCompat.Dialog相反


I have a datepicker that's showing a header on Lollipop, it looks like this

I want to either change the color of the big date in the header from black to white, or remove the header altogether, I don't care which. I've tried changing textColorPrimary, textColor and titleTextColor but it has no effect.

解决方案

Well I have no clue what's the parent theme that you have for your Date Picker theme. Let's say you have a custom theme for your Date Picker like below,

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

Now Ctrl + click on Theme.AppCompat.Light which leads you to a new way ;) where you can find what you are looking for meaning here your issue is only about the head text but you might wish to change another views color, so that's the place you need to have a look.

And as the answer create a custom theme like below and add this attribute with the color you like

android:textColorPrimaryInverse

should do the trick for you.

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

Feel free to use your own colors and code(I copied code from this) and it will do the job!

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();

Image : android:textColorPrimaryInverse with Theme.AppCompat.Dialog

这篇关于更改DatePicker标题文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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