Skip to content
黄海彬 edited this page Sep 14, 2018 · 4 revisions

CalenderView 详细介绍,使用请自行参考Demo!!!

此框架的设计思想

该框架采用插拔式设计(类似自定义Behavior),框架本身做好了各种逻辑,不对客户端渲染做限制,因此界面显示均由客户端自行控制。 插拔式接口如下:

<attr name="month_view" format="string" /><!--自定义月视图路径-->
<attr name="week_view" format="string" /> <!--自定义周视图路径-->
<attr name="week_bar_view" format="string" /> <!--自定义星期栏路径-->

你可以按自己的需求自定义自己的视图

public class CustomMonthView extends MonthView

public class CustomWeekView extends WeekView

public class CustomWeekBar extends WeekBar

public class CustomRangeMonthView extends RangeMonthView

public class CustomRangeWeekView extends RangeWeekView

当定义好之后,可以自行在xml指定路径或者使用java API

 app:month_view="com.haibin.calendarviewproject.custom.CustomMonthView"
 app:week_view="com.haibin.calendarviewproject.custom.CustomWeekView"

 mCalendarView.setWeekView(CustomWeekView.class);
 mCalendarView.setMonthView(CustomMonthView.class);
 mCalendarView.setWeekBar(CustomWeekBar.class);

框架常见问题

  1. 为什么仅显示周视图需要指定calendar_content_view_id?
月视图收缩后才是周视图,但月视图未收缩部分需要ContentView视图来遮挡,如果还不明白的请将ContentView背景设置为透明
同样的,很多场景需要不断变化视图,有时仅显示周视图、有时仅月视图、有时两者都要,该框架可以充分支持这种动态变换。
  1. 是否支持周末、节日等颜色单独?
假如你喜欢小米的日历日期快速跳转,那么你也可以使用类似的控件通过调用各种 CalendarView.scrollToCalendar() API
  1. 是否可隐藏农历?
收到很多这样的issue,框架本身没有这种说法,该显示什么、要不要显示什么,你自己说了算,自行绘制即可,看demo!!!
  1. 限制日期?拦截日期?
<attr name="min_year" format="integer" />
<attr name="max_year" format="integer" />
<attr name="min_year_month" format="integer" />
<attr name="max_year_month" format="integer" />
<attr name="min_year_day" format="integer" />
<attr name="max_year_day" format="integer" />

mCalendarView.setRange();//设置范围

mCalendarView.setOnCalendarInterceptListener(this);//按你的条件来拦截任意日期

  1. 是否支持自定义周起始?
你可以定制周一、周日、周六为视图起始时间,使用 week_start_with attr 或者 mCalendarView.setWeekStarWithXXX()

  1. 关于UI的一系列问题
UI本身是靠自己绘制的,非常简单,不懂的请优先看Demo,看的懂Java自然就能看的懂怎么绘制界面

写在最后

框架本身是为了解决各种各样的场景而设计的,不是仅针对一个需求的.

Clone this wiki locally