material-calendarvie 使用记录,以及一些属性的修改。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a940659387/article/details/83418007

1.设置选择的背景色

mCalendarView.setSelectionColor(Color.parseColor("#dd5050"));

2.修改选中背景颜色的大小(这里是减少10dip)
DayView中

private void calculateBounds(int width, int height) {
    final int radius = Math.min(height, width);
    final int offset = Math.abs(height - width) / 2;

    // Lollipop platform bug. Circle drawable offset needs to be half of normal offset
    final int circleOffset =
        Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP ? offset / 2 : offset;

    if (width >= height) {
      tempRect.set(offset, 0, radius + offset, height);
      circleDrawableRect.set(circleOffset+dip_10, 0+dip_10, radius-dip_10 + circleOffset, height-dip_10)//修改选中背景的大小。
    } else {
      tempRect.set(0, offset, width, radius + offset);
      circleDrawableRect.set(0, circleOffset, width, radius + circleOffset);
    }
  }
}

3.设置周五周六周日不可点击
CalendarPagerView中

protected void updateUi() {
    for (DayView dayView : dayViews) {
      CalendarDay day = dayView.getDate();
      boolean enable = true;
      DayOfWeek dayOfWeek = day.getDate().getDayOfWeek();
      switch (dayOfWeek){//设置周五周六周日不可点击
        case FRIDAY:
        case SATURDAY: 
        case SUNDAY:
          enable = false;
          break;
      }
      dayView.setupSelection(showOtherDates, day.isInRange(minDate, maxDate)&&enable, isDayEnabled(day));
    }
    postInvalidate();
  }

猜你喜欢

转载自blog.csdn.net/a940659387/article/details/83418007