CalenderView

Android上一个优雅、高度自定义、性能高效的日历控件,支持标记、自定义颜色、农历等。Canvas绘制,速度快、占用内存低,3.0.0版本全新重构,支持简单重新即可实现任意自定义布局、自定义UI,支持收缩展开、性能非常高效,

简单的说老版本是使用RecyclerView + Canvas 的、这种方式对于自定义控件的复杂度下降了很多,但是相反内存占用却上升了,如果使用一个View替换RecyclerView,则控件数相比会下降130+,每个页面就有43个控件,

3.0.0版本内存和效率优势提升相当明显,而且真正做到收缩+展开,适配多种场景,支持同时多种颜色标记日历事务,更多参考用法请移步Demo。

Gradle

compile 'com.haibin:calendarview:3.0.0'

com.haibin

calendarview

3.0.0

pom

如果你需要完全定制UI,参考demo,简单几步即可绘制你需要的效果,一般只需要实现三个回调函数绘制你需要的特效即可,真正做到热插拔效果,方便大众定制UI需求

效果预览

收缩展开的魅族风格效果

     

下标和多彩风格

     

快速年份月份切换

     

使用方法

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

app:calendar_content_view_id="@+id/recyclerView">

android:id="@+id/calendarView"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#fff"

app:calendar_card_view="com.haibin.calendarviewproject.simple.SimpleCalendarCardView"

app:calendar_height="50dp"

app:current_month_text_color="#333333"

app:current_month_lunar_text_color="#CFCFCF"

app:min_year="2004"

app:other_month_text_color="#e1e1e1"

app:scheme_text="假"

app:scheme_text_color="#333"

app:scheme_theme_color="#333"

app:selected_text_color="#fff"

app:selected_theme_color="#333"

app:week_background="#fff"

app:week_text_color="#111" />

android:id="@+id/recyclerView"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#d4d4d4" />

attrs

CalendarView api

public int getCurDay(); //今天

public int getCurMonth(); //当前的月份

public int getCurYear(); //今年

public void showSelectLayout(final int year); //快速弹出年份选择月份

public void closeSelectLayout(final int position); //关闭选择年份并跳转日期

public void setOnDateChangeListener(OnDateChangeListener listener);//添加事件

public void setOnDateSelectedListener(OnDateSelectedListener listener);//日期选择事件

public void setSchemeDate(List mSchemeDate);//标记日期

public void update();//动态更新

public Calendar getSelectedCalendar(); //获取选择的日期

/**

* 设置背景色

*

* @param monthLayoutBackground 月份卡片的背景色

* @param weekBackground 星期栏背景色

* @param lineBg 线的颜色

*/

public void setBackground(int monthLayoutBackground, int weekBackground, int lineBg)

/**

* 设置文本颜色

*

* @param curMonthTextColor 当前月份字体颜色

* @param otherMonthColor 其它月份字体颜色

* @param lunarTextColor 农历字体颜色

*/

public void setTextColor(int curMonthTextColor,int otherMonthColor,int lunarTextColor)

/**

* 设置选择的效果

*

* @param style 选中的style CalendarCardView.STYLE_FILL or CalendarCardView.STYLE_STROKE

* @param selectedThemeColor 选中的标记颜色

* @param selectedTextColor 选中的字体颜色

*/

public void setSelectedColor(int style, int selectedThemeColor, int selectedTextColor)

/**

* 设置标记的色

*

* @param style 标记的style CalendarCardView.STYLE_FILL or CalendarCardView.STYLE_STROKE

* @param schemeColor 标记背景色

* @param schemeTextColor 标记字体颜色

*/

public void setSchemeColor(int style, int schemeColor, int schemeTextColor)

/**

* 设置星期栏的背景和字体颜色

*

* @param weekBackground 背景色

* @param weekTextColor 字体颜色

*/

public void setWeeColor(int weekBackground, int weekTextColor)

CalendarLayout api

public void expand(); //展开

public void shrink(); //收缩

如果你需要完全定制UI,参考demo,简单几步即可绘制你需要的效果

public class SimpleCalendarCardView extends BaseCalendarCardView {

private int mRadius;

public SimpleCalendarCardView(Context context) {

super(context);

}

@Override

protected void onPreviewHook() {

mRadius = Math.min(mItemWidth, mItemHeight) / 5 * 2;

mSchemePaint.setStyle(Paint.Style.STROKE);

}

@Override

protected void onLoopStart(int x, int y) {

}

@Override

protected void onDrawSelected(Canvas canvas, Calendar calendar, int x, int y, boolean hasScheme) {

int cx = x + mItemWidth / 2;

int cy = y + mItemHeight / 2;

canvas.drawCircle(cx, cy, mRadius, mSelectedPaint);

}

@Override

protected void onDrawScheme(Canvas canvas, Calendar calendar, int x, int y) {

int cx = x + mItemWidth / 2;

int cy = y + mItemHeight / 2;

canvas.drawCircle(cx, cy, mRadius, mSchemePaint);

}

@Override

protected void onDrawText(Canvas canvas, Calendar calendar, int x, int y, boolean hasScheme, boolean isSelected) {

float baselineY = mTextBaseLine + y;

int cx = x + mItemWidth / 2;

if (hasScheme) {

canvas.drawText(String.valueOf(calendar.getDay()),

cx,

baselineY,

calendar.isCurrentDay() ? mCurDayTextPaint :

calendar.isCurrentMonth() ? mSchemeTextPaint : mOtherMonthTextPaint);

} else {

canvas.drawText(String.valueOf(calendar.getDay()), cx, baselineY,

calendar.isCurrentDay() ? mCurDayTextPaint :

calendar.isCurrentMonth() ? mCurMonthTextPaint : mOtherMonthTextPaint);

}

}

}

Licenses

Copyright (C) 2013 huanghaibin_dev huanghaibin_dev@163.com

Licensed under the Apache License, Version 2.0 (the "License");

you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

android 魅族日历,GitHub - yhyonghao/CalendarView: CalenderView_Meizu 魅族风格日历相关推荐

  1. android自定义选年控件,Android精美日历控件CalendarView自定义使用完全解析

    项目github地址 此框架采用组合的方式,各个模块互相独立,可自由采用各种提供的控件组合,完全自定义自己需要的UI,周视图和月视图可通过简单自定义任意自由绘制,不怕美工提需求!!!下面教程将介绍如何 ...

  2. 记一次Android第三方日历控件CalendarView的使用

    一.文章背景 用过两个日历控件的库,有用viewpager实现的,也有用canvas实现的.在实际使用过程中,发现使用canvas实现的calendarView切换下一月和下一年这种操作时切换更流畅. ...

  3. android电动机动画,不愧是Android中最大的线性马达,魅族mEngine即将带来4D游戏振感...

    原标题:不愧是Android中最大的线性马达,魅族mEngine即将带来4D游戏振感 目前越来越多的手机厂商都非常重视用户的体验,在自己的定制系统上增加越来越多人性化的设计,但软件一顶离不开硬件的支持 ...

  4. 魅族mx四核即将使用android,第一款国产上市四核 魅族MX四核手机试玩

    本文导航第1页:魅族MX四核:延续魅族MX的外观设计 魅族MX四核:延续魅族MX的外观设计 今年上半年的手机市场可以用"国产"和"四核"两个关键字来形容,关 ...

  5. Android沉浸式状态栏(包含 小米、魅族)

    Android沉浸式状态栏(包含 小米.魅族) 今天魅族手机 flyme 6(android 7.0) 状态栏问题搞的我晕头转向,后来找到flyme开放平台 才将问题解决.因此,有必要记录一下2018 ...

  6. 日历控件CalendarView

    API 11中新加了CalendarView控件,即日历控件.但是如果需要在3.0以下系统中支持,就需要自定义了. https://github.com/square/android-times-sq ...

  7. 魅族mx3升级到android6.0,魅族MX3升级基于安卓4.4的Flyme3.6.1A体验版流程教程介绍

    上周就传闻,魅族本周一将推出基于安卓4.4的Flyme 4.0 OS系统,适配魅族MX3,今天下午,魅族如期发布了安卓4.4的MX3 Flyme OS 3.6.1A体验版.新版固件新增了Android ...

  8. 魅族mx3升级到android6.0,魅族MX3的手机系统是什么?魅族MX3能升级安卓4.3吗?

    魅族MX3的手机系统是什么 魅族MX3运行于 Android 4.2.2 系统版本,魅族也随手机带来最新的 Flyme 3.0 操作环境.其中 Smart Bar 2.0 和侧滑清单对大屏幕进行优化. ...

  9. 使用Android Studio向GitHub提交代码

    使用Android Studio向GitHub提交代码 在GitHub上创建一个仓库 填写仓库名称.描述.类型(公有.私有)等信息,点击创建 到此,成功创建了我们的仓库,并且初始化创建了README. ...

最新文章

  1. android从放弃到精通 第五天 excellent
  2. shell实例第9讲:判断用户输入的是否为IP地址
  3. 使用 C# 开发智能手机软件:推箱子(二十三)
  4. 提问赠书 | 我们请了 7 位云原生专家,等你来问
  5. 手机app常见bug积累
  6. GIT 中同时 push 代码到多个远程仓库
  7. python使用redis_python应用中使用redis的几个思考
  8. fastify 后台_如何使用Fastify启动和运行
  9. nginx ngx_http_index_module(默认初始页)
  10. 树结构的储存与特点(相关基础知识)
  11. bzoj4820[SDOI2017]硬币游戏
  12. install opencv on mac and use it in xcode
  13. java学生管理系统
  14. ps入门第4天_ps画笔工具知识汇总_自定义画笔工具_画笔画彩带
  15. Bing必应搜索引擎打开新标签默认页的修改
  16. xThunder —— 完美支持Firefox的迅雷,旋风调用扩展
  17. qt 不规则图形 消除锯齿
  18. 一个苏州IT人的5年挨踢经历-------面试,薪资,企业,经历全方位揭示(之二)
  19. 2019东南大学计算机考研录取,东南大学2019年硕士研究生拟录取名单公示-不带成绩...
  20. 2个月快速通过PMP证书的经验

热门文章

  1. Java程序设计梁勇第十版第八章编程练习题
  2. 集体备课模板_集体备课记录模板
  3. caffe安装使用、样本制作、网络修改、错误重新训练!
  4. Kafka从入门到精通(八)Kafka原理
  5. 烤仔万花筒 | 明日,ART101首席艺术家LULU作品将于Tspace开售
  6. python常用数据作图--matplotlib用法(相关设置及常用图)
  7. Python三角形代码
  8. 量子计算机淘汰了吗,量子计算机将淘汰目前的所有计算机
  9. ios应用相关的性能优化及参考文档
  10. 汇编语言----mul指令