Skip to content

自定义属性

yannecer edited this page Jul 4, 2024 · 21 revisions

自定义属性

自定义属性,仅针对本库中内置的一个CalendarPainter的实现类InnerPainter,
如果是自定义的绘制类或者自定义的CalendarAdapter,则属性不生效
法定节假日分两部分,可以设置文字(休、班等)属性,也可以设置drawable,如果设置了drawable则文字相关属性不再生效
属性中使用drawable的,xml中需写明size属性
属性中关于选中的,都设置了今天选中和默认选中两种属性,以便于区分今天的不同

日历自定义属性包含

自定义属性 以 次文件为准

日历选中属性

Attributes format describe
todayCheckedBackground reference 今天选中的背景 drawable(xml中需写明size属性)
defaultCheckedBackground reference 其他日期选中的背景 drawable(xml中需写明size属性)

公历日期属性

Attributes format describe
todayCheckedSolarTextColor color 今天选中的公历字体颜色
todayUnCheckedSolarTextColor color 今天不选中的公历字体颜色
defaultCheckedSolarTextColor color 默认选中的公历字体颜色
defaultUnCheckedSolarTextColor color 默认不选中公历字体颜色
solarTextSize dimen 公历字体大小
solarTextBold boolean 公历字体是否加粗

农历日期属性

Attributes format describe
showLunar boolean 是否显示农历
todayCheckedLunarTextColor color 今天选中时农历颜色
todayUnCheckedLunarTextColor color 今天不选中时农历颜色
defaultCheckedLunarTextColor color 默认选中时农历颜色
defaultUnCheckedLunarTextColor color 默认不选中时农历颜色
lunarTextSize dimen 农历字体大小
lunarTextBold boolean 农历字体是否加粗
lunarDistance dimen 农历文字到文字中心的距离

法定节假日文字属性

Attributes format describe
showHolidayWorkday boolean 是否显示节假日
holidayText string 节假日文字
workdayText string 工作日文字
holidayWorkdayTextSize dimen 节假日字体大小
holidayWorkdayTextBold boolean 节假日字体是否加粗
holidayWorkdayDistance dimen 节假日文字距离中心距离
holidayWorkdayLocation eunm 节假日文字的位置(top_right、top_left、bottom_right、bottom_left)
todayCheckedHolidayTextColor color 今天选中时节假日字体颜色
todayUnCheckedHolidayTextColor color 今天未选中时节假日字体颜色
defaultCheckedHolidayTextColor color 默认选中时节假日字体颜色
defaultUnCheckedHolidayTextColor color 默认未选中时节假日字体颜色
todayCheckedWorkdayTextColor color 今天选中的工作日字体颜色
todayUnCheckedWorkdayTextColor color 今天选中的工作日颜色
defaultCheckedWorkdayTextColor color 默认选中时工作日字体颜色
defaultUnCheckedWorkdayTextColor color 默认未选中时工作日字体颜色

节假日drawable属性

上面的文字属性除去字体样式的属性,drawable同样适用
Attributes format describe
todayCheckedHoliday reference 今天选中时节假日 drawable
todayUnCheckedHoliday reference 今天不选中时节假日 drawable
defaultCheckedHoliday reference 默认选中时节假日 drawable
defaultUnCheckedHoliday reference 默认不选中时节假日 drawable
todayCheckedWorkday reference 今天选中时工作日 drawable
todayUnCheckedWorkday reference 今天不选中工作日 drawable
defaultCheckedWorkday reference 默认选中时工作日 drawable
defaultUnCheckedWorkday reference 默认不选中时工作日 drawable

日期标记属性

Attributes format describe
todayCheckedPoint reference 今天选中标记 drawable
todayUnCheckedPoint reference 今天不选中时标记 drawable
defaultCheckedPoint reference 默认选中时标记 drawable
defaultUnCheckedPoint reference 默认不选中时标记 drawable
pointLocation emun 标记日期位置 (up、down)
pointDistance dimen 标记点到文字中心的距离

数字背景属性

Attributes format describe
showNumberBackground boolean 是否显示数字背景
numberBackgroundTextSize dimen 数字背景字体大小
numberBackgroundTextColor color 数字背景字体颜色
numberBackgroundAlphaColor int 数字背景字体透明度(0-255)

日历其他属性

Attributes format describe
firstDayOfWeek emun 日历一周开始是周日或周一(sunday、monday),默认周日
allMonthSixLine boolean 月日历是否全部6行
lastNextMonthClickEnable boolean 月日历上下月是否可点击
calendarBackground reference 日历背景(数字背景优先,如果设置了显示数字背景,此处不生效)
lastNextMothAlphaColor int 上下月字体透明度(0-255),包含,公历、农历、节假日等
disabledAlphaColor int 不可用日期(超出日期区间)字体透明度(0-255),包含,公历、农历、节假日等
disabledString string 点击不可用的日期提示语

折叠日历属性(Miui9Calendar、Miui10Calendar、EmuiCalendar)属性

以上公历、农历、节假日等属性,折叠属性同样适用
Attributes format describe
defaultCalendar emun 折叠日历的默认展示日历(month、week),默认暂时月
calendarHeight dimen 折叠日历月日历的高度
animationDuration int 折叠日历动画时间
stretchCalendarEnable boolean 折叠日历是否可以再下拉
stretchCalendarHeight dimen 拉伸之后的月日历高度
stretchTextSize dimen 拉伸之后文字的大小
stretchTextBold boolean 拉伸之后文字是否加粗
stretchTextColor color 拉伸之后文字的颜色
stretchTextDistance color 拉伸显示的字体距离矩形中心的距离