日历控件CalendarView的使用

项目需要用到CalendarView故而整理CanlendarView的相关API

Gradle

implementation 'com.haibin:calendarview:3.5.5'

CalendarLayout

这是辅助类,当需要日历折叠功能的时候,用它包裹住CalendarView

//CalendarLayout api
public void expand(); //展开
public void shrink(); //收缩
public boolean isExpand();//是否已经展开

日历显示模式


      
      
      


       
      


CalendarView

可通过attr配置



        
        
        
        

        
        

        
        
        
        
        
        
        
        

        
        
        

        
        
        
        
        
        


        
        
        
        
        
        
        
        

        
        
        
        

       
        
              
              
              
        

         
         
             
             
             
         
    
//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 setRange(int minYear, int minYearMonth, int maxYear, int maxYearMonth) //设置日期范围
public void setOnYearChangeListener(OnYearChangeListener listener);//年份切换事件
public void setOnDateSelectedListener(OnDateSelectedListener listener);//日期选择事件
public void setSchemeDate(List mSchemeDate);//标记日期
public void update();//动态更新
public Calendar getSelectedCalendar(); //获取选择的日期
public void scrollToPre();//滚动到上一个月
public void scrollToNext();//滚动到下一个月
public void scrollToCalendar(int year, int month, int day);//滚动到指定日期
public void setBackground(int monthLayoutBackground, int weekBackground, int lineBg)//设置背景色
public void setTextColor(int curMonthTextColor,int otherMonthColor,int lunarTextColor)//设置文本颜色
public void setSelectedColor(int style, int selectedThemeColor, int selectedTextColor)//设置选择的效果
public void setSchemeColor(int style, int schemeColor, int schemeTextColor)//设置标记的色
public void setBackground(int yearViewBackground, int weekBackground, int lineBg)//设置背景色

你可能感兴趣的:(日历控件CalendarView的使用)