public NCalendar(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setMotionEventSplittingEnabled(false); Attrs attrss = AttrsUtil.getAttrs(context, attrs); int duration = attrss.duration; monthHeight = attrss.monthCalendarHeight; STATE = attrss.defaultCalendar; weekHeight = monthHeight / 5; isWeekHold = attrss.isWeekHold; calendarPainter = new InnerPainter(attrss); weekCalendar = new WeekCalendar(context, attrss,calendarPainter); monthCalendar = new MonthCalendar(context, attrss,calendarPainter, duration, this); childLayout = new ChildLayout(getContext(), attrs, monthHeight, duration, this); monthCalendar.setOnMonthSelectListener(this); weekCalendar.setOnWeekSelectListener(this); childLayout.setBackgroundColor(attrss.bgChildColor); setCalenadrState(STATE); childLayoutLayoutTop = STATE == Attrs.WEEK ? weekHeight : monthHeight; post(new Runnable() { @Override public void run() { monthRect = new Rect(0, 0, monthCalendar.getWidth(), monthCalendar.getHeight()); weekRect = new Rect(0, 0, weekCalendar.getWidth(), weekCalendar.getHeight()); monthCalendar.setY(STATE == Attrs.MONTH ? 0 : getMonthYOnWeekState()); childLayout.setY(STATE == Attrs.MONTH ? monthHeight : weekHeight); } }); }