近期项目有做日历选择控件需求,综合各种自己实现耗时耗力bug多、很多封装好的无法满足项目需求等因素,在这里分享一篇成熟的第三方日历选择控件博客
gradle添加
compile ‘com.haibin:calendarview:3.3.1’
xml文件
SimpleMonthView和SimpleWeekView文件,博主博客项目链接里面有,直接复制就好了
<com.haibin.calendarview.CalendarView
android:id="@+id/calendarview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_calendar_dialog"
app:calendar_height="46dp"
app:current_month_lunar_text_color="#CFCFCF"
app:current_month_text_color="@color/colorTextGray"
app:min_year="2004"
app:month_view="per.chen.demo.calendardialog.SimpleMonthView"
app:other_month_text_color="#e1e1e1"
app:scheme_text_color="@color/colorTextGray"
app:scheme_theme_color="@color/colorTheme"
app:selected_text_color="#fff"
app:selected_theme_color="@color/colorTheme"
app:week_background="#fff"
app:week_text_color="@color/colorTextPre"
app:week_view="per.chen.demo.calendardialog.SimpleWeekView"
app:year_view_day_text_color="@color/colorTextGray"
app:year_view_day_text_size="9sp"
app:year_view_month_text_color="@color/colorTheme"
app:year_view_month_text_size="20sp"
app:year_view_scheme_color="@color/colorTheme" />
这个自定义控件很多属性都可以设置,我自己重复造轮子,把这个封装到一个Dialog里面,使用的时候直接调用,非常方便
附上图片
参考于:https://blog.csdn.net/huanghaibin_dev/article/details/79040147
感谢作者分享~