implementation ‘com.necer.ncalendar:ncalendar:5.0.2’
<com.necer.view.WeekBar
android:layout_width="match_parent"
android:layout_height="40dp"
android:textColor="#FF64C7AF"
android:textSize="14sp" />
<com.necer.calendar.Miui10Calendar
android:id="@+id/monthCalendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:solarTextSize="14sp"
app:stretchTextColor="#333333">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</com.necer.calendar.Miui10Calendar>
private void initCalendar() {
binding.monthCalendar.setCheckMode(CheckModel.SINGLE_DEFAULT_CHECKED);
binding.monthCalendar.setCalendarState(CalendarState.WEEK);
binding.monthCalendar.setOnCalendarChangedListener(new OnCalendarChangedListener() {
@Override
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate, DateChangeBehavior dateChangeBehavior) {
binding.tvDate.setText(year + "年" + month + "月");
mLocalDate = localDate;
EventBus.getDefault().post(new EventEntity(EventBusConstants.UPDATE_DIARY,localDate));
initCalendarData(year,month);
}
});
}