仅在日期选择器Android中更改所选日期的颜色 [英] Change the color of selected date only in date picker android
问题描述
我正在使用日期选择器,并且需要用不同的颜色设置它的样式.除了选定的日期颜色,所有其他东西都工作正常.选择的日期颜色默认为"android:textColorPrimaryInverse",在我的情况下为红色,对话框的背景为白色,"android:colorControlHighlight"和"android:colorControlActivated"也为红色.
I am using date picker and I need to style it with different colors. All things are working fine except the selected date color. The thing is selected date color takes "android:textColorPrimaryInverse" as default which in my case is red , background of the dialog is white and the "android:colorControlHighlight" and "android:colorControlActivated" is also red.
这意味着不会显示所选的文本颜色.我需要将其显示为白色,但是问题是,如果我将"android:textColorPrimaryInverse"更改为白色,则标题将不会显示,因为背景是白色.
This means the selected text color doesn't show.I need that to be shown as white but the issue is if I change"android:textColorPrimaryInverse" to white my title won't appear as the background is white.
这是我的样式文件:
<style name="DialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/color_white</item>
<item name="android:textColorPrimaryInverse">@color/red</item>
<item name="android:textColorSecondaryInverse">@color/red</item>
<item name="android:datePickerStyle">@style/MyDatePickerStyle</item>
<item name="buttonBarButtonStyle">@style/DialogButtonStyle</item>
<item name="android:colorControlHighlight">@color/red</item>
<item name="android:colorControlActivated">@color/red</item>
</style>
这就是我显示对话框的方式
and this is how I show my dialog
new DatePickerDialog(mActivity, R.style.DialogTheme, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
//DO SOMETHING
}
}, 2015, 02, 26).show();
推荐答案
使用;
<item name="android:textColorPrimaryInverse">@color/white</item>
<item name="android:colorControlActivated">@color/red</item>
这篇关于仅在日期选择器Android中更改所选日期的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!