Android知识分享之显示日历

博主介绍:本人专注于Android/java/数据库/微信小程序技术领域的开发,以及有好几年的计算机毕业设计方面的实战开发经验和技术积累;尤其是在安卓(Android)的app的开发和微信小程序的开发,很是熟悉和了解;本人也是多年的Android开发人员;希望我发布的此篇文件可以帮助到您;

🍅点个关注不迷路!🍅

目录

效果演示

一、Gradle配置

二、xml布局文件配置

三、日历添加小圆点 

四、点击事件

五、支持的属性

关注点赞


效果演示

一、Gradle配置

dependencies {
implementation 'com.necer.ncalendar:ncalendar:4.0.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
}

二、xml布局文件配置

<com.necer.calendar.EmuiCalendar
    android:id="@+id/emuiCalendar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:holidayColor="#F29B38"
    app:isShowLunar="true"
    app:isDefaultSelect="false"
    app:lunarHolidayTextColor="#F29B38"
    app:pointDistance="15dp"
    app:pointColor="#f00"
    app:selectCircleColor="@color/main_color"
    app:solarHolidayTextColor="#F29B38"
    app:solarTermTextColor="#F29B38"
    app:todaySolarTextColor="#F29B38">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/tv_lunar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:background="#f5f5f5"
            android:textColor="#333333"
            android:textSize="13sp" />

    </android.support.v4.widget.NestedScrollView>
</com.necer.calendar.EmuiCalendar>

三、日历添加小圆点 

List<String> pointList = Arrays.asList("2004-01-01", "2004-01-02");
InnerPainter innerPainter = (InnerPainter) miui10Calendar.getCalendarPainter();
innerPainter.setPointList(pointList);

效果如图:

四、点击事件

emuiCalendar.setOnCalendarChangedListener(new OnCalendarChangedListener() {
    @Override
    public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate) {
        tv_result.setText(year + "年" + month + "月" + "   当前选中 " + localDate);
        listSchedulChoice(false,localDate.toString());
    }
});

说明:emuiCalendar是日历控件信息

  

五、支持的属性

Attributesformadescribe
solarTextColorcolor公历日期的颜色
lunarTextColorcolor农历日期的颜色
solarHolidayTextColorcolor公历节假日的颜色
lunarHolidayTextColorcolor农历节假日的颜色
solarTermTextColorcolor节气颜色
selectCircleColorcolor选中圈的颜色
holidayColorcolor法定节休息日颜色
workdayColorcolor法定节调休工作日颜色
bgEmuiCalendarColorcolorEmui日历的背景
bgChildColorcolor日历包含子view的背景
todaySelectContrastColorcolor今天被选中是其他元素的对比色,比如 农历,圆点等
pointColorcolor小圆点的颜色
startDatestring日期区间开始日期
endDatestring日期区间结束日期
isDefaultSelectboolean是否默认选中
isDefaultSelectFitstboolean是否默认翻页选中第一天
isMultipleSelectboolean是否多选
alphaColorinteger不是本月的日期颜色的透明度0-255
disabledAlphaColorinteger日期区间之外的地日颜色的透明度0-255
disabledStringstring点击日期区间之外的日期提示语
todaySolarTextColorcolor今天不选中的颜色
todaySolarSelectTextColorcolor今天选中的颜色
selectCircleRadiusdimension选中圈的半径
solarTextSizedimension公历日期字体大小
lunarTextSizedimension农历日期字体大小
lunarDistancedimension农历日期到公历字体的距离
holidayTextSizedimension法定节假日字体的大小
holidayDistancedimension法定节假日到公历的距离
pointDistancedimension小圆点到公历的距离
hollowCircleStrokedimension空心圆的宽度
calendarHeightdimension日历的高度
durationinteger日历自动滑动的时间
isShowLunarboolean是否显示农历
isShowHolidayboolean是否显示法定节假日
isWeekHoldboolean周状态是否固定,默认不固定
isDefaultSelectboolean是否默认选中(只对单个月日历或者周日历有效)
defaultCalendarenum默认视图 week 或者 month
pointLocationenum指示点的文职 up(在公历的上方) 或者 down(在公历的下方) 默认是up
firstDayOfWeekenum一周开始的星期天还是星期一 sunday 或者 monday 默认是sunday
holidayLocationenum法定节假日相对公历日期的位置 top_right(右上方)、top_left(左上方)、bottom_right(右下方)、bottom_left(左下方)

关注点赞

大家点赞、收藏、关注、评论啦 、查看👇🏻👇🏻👇🏻获取联系方式👇🏻👇🏻👇🏻

  • 15
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Android毕业设计源码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值