如何为日历中的禁用日期设置背景颜色

时间:2017-03-12 18:59:22

标签: android datepicker android-datepicker

您好我想使用wdullaer MaterialDateTimePicker库更改calendar.am中禁用日期的背景颜色。任何正文请给我一个想法怎么做。 这是源链接 https://github.com/wdullaer/MaterialDateTimePicker/

1 个答案:

答案 0 :(得分:0)

为什么不能使用android-betterpickers库,在这种情况下可以正常工作,您只需要编写自定义样式并在对话框中进行如下设置即可:

样式:

<style name="calenderPicker">
    <item name="bpHeaderBackgroundColor">?attr/colorPrimary</item>
    <item name="bpPreHeaderBackgroundColor">?attr/colorPrimaryDark</item>
    <item name="bpHeaderUnselectedTextColor">@color/radial_gray_light</item>
    <item name="bpHeaderSelectedTextColor">@color/bpWhite</item>
    <item name="bpBodyBackgroundColor">@color/bpWhite</item>
    <item name="bpBodySelectedTextColor">?attr/colorPrimary</item>
    <item name="bpBodyUnselectedTextColor">@color/date_picker_text_normal</item>
    <item name="bpButtonsBackgroundColor">@color/bpWhite</item>
    <item name="bpButtonsTextColor">?attr/colorPrimary</item>
    <item name="bpRadialBackgroundColor">@color/radial_gray_light</item>
    <item name="bpRadialTextColor">?attr/colorPrimary</item>
    <item name="bpRadialPointerColor">?attr/colorPrimary</item>
    <item name="bpAmPmCircleColor">?attr/colorPrimary</item>
    <item name="bpDisabledDayTextColor">@color/colorPrimary</item> //DISABLED DAYS
</style>

JAVA:

CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment()
            .setDisabledDays(disabledDays)
            .setThemeCustom(R.style.calenderPicker);