美文网首页
Android MaterialCalendarView 日历

Android MaterialCalendarView 日历

作者: 风就那么大 | 来源:发表于2019-03-22 09:43 被阅读0次

MaterialCalendarView项目开源地址:

https://github.com/prolificinteractive/material-calendarview

集成清单

1.添加compile'com.prolificinteractive:material-calendarview:1.4.2'

2.添加日历控件到布局中

//设置周的文本calendarView.setWeekDayLabels(newString[]{"日","一","二","三","四","五","六"});

//日期点击事件calendarView.setOnDateChangedListener(this);

calendarView.setSelectedDate(CalendarDay.today());//当日选中

//设置选中日期颜色。

calendarView.setSelectionColor(getResources().getColor(R.color.color_fdd369));

calendarView.setTitleFormatter(new DateFormatTitleFormatter(DateTimeFormatter.ofPattern("yyyy年MM月")));//设置当前标题日期格式

calendarView.setSelectionMode(MaterialCalendarView.SELECTION_MODE_MULTIPLE);//默认单选模式  这里选择多选模式

calendarView.setDateSelected(CalendarDay.from(2019, 3, 25), true);//设置当前日期为选中状态

<style name="MaterialCalendarTextStyelNormal">

    <item name="android:textSize">12sp

    <item name="android:textColor">@color/colorWhite

</style>

//日历头部字体样式设置

app:mcv_headerTextAppearance="@style/MaterialheaderTextStyelNormal"

//日历时间字体样式设置

app:mcv_weekDayTextAppearance="@style/MaterialCalendarTextStyelNormal"

//设置左边 和右边箭头 图片

app:mcv_leftArrow="@mipmap/leftgo"

app:mcv_rightArrow="@mipmap/rightgo"

//设置头部  标题日期动画方式 横向 还是 竖向 过度

app:mcv_titleAnimationOrientation="horizontal"

//设置日历时间 之间高度

app:mcv_tileHeight="30dp"

//日历从左到右  第一周显示的  (此处是星期天)

app:mcv_firstDayOfWeek="sunday"

相关文章

网友评论

      本文标题:Android MaterialCalendarView 日历

      本文链接:https://www.haomeiwen.com/subject/uhnkvqtx.html