Android 突出显示日历中的多个选定日期

Android 突出显示日历中的多个选定日期,android,android-studio,Android,Android Studio,我想突出显示多个选定日期,如缺席(红色)、出席(绿色)和假日(蓝色)。我展示了许多网站或github或stackoverflow的答案,但并没有找到完美的解决方案。 还可以设置显示日历的最短日期和最长日期 我的问题是这样的,但没有找到解决办法 请帮我找到完美的解决方案。 1.使用第三方库McalenderView 2.将以下内容添加到渐变中:- 'sun.bob:mcalendarview:1.0.0' 请尝试以下代码:- 3.一些代码:- calendarView = ((MCalendar

我想突出显示多个选定日期,如缺席(红色)、出席(绿色)和假日(蓝色)。我展示了许多网站或github或stackoverflow的答案,但并没有找到完美的解决方案。 还可以设置显示日历的最短日期和最长日期

我的问题是这样的,但没有找到解决办法

请帮我找到完美的解决方案。

1.使用第三方库McalenderView

2.将以下内容添加到渐变中:-

'sun.bob:mcalendarview:1.0.0'
请尝试以下代码:-

3.一些代码:-

calendarView = ((MCalendarView) view.findViewById(R.id.calendar_exp));

    ArrayList<DateData> dates=new ArrayList<>();
    dates.add(new DateData(2018,04,26));
    dates.add(new DateData(2018,04,27));

    for(int i=0;i<dates.size();i++) {
        calendarView.markDate(dates.get(i).getYear(),dates.get(i).getMonth(),dates.get(i).getDay());//mark multiple dates with this code.
    }


    Log.d("marked dates:-",""+calendarView.getMarkedDates());//get all marked dates.
calendarView=((MCalendarView)view.findviewbyd(R.id.calendar_exp));
ArrayList日期=新建ArrayList();
日期。添加(新日期数据(2018,04,26));
日期。添加(新日期数据(2018,04,27));

对于(int i=0;i请尝试使用以下库:

dependencies {
implemantation 'com.savvi.datepicker:rangepicker:1.3.0'
}
内部布局:

 <com.savvi.rangedatepicker.CalendarPickerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/calendar_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbarStyle="outsideOverlay"
    android:clipToPadding="false"
    app:tsquare_orientation_horizontal="false"
    app:tsquare_dividerColor="@color/transparent"
    app:tsquare_headerTextColor="@color/custom_header_text"
    /> 

更多信息:

我已经尝试过了,这很好,但我也想使用多种颜色。根据我的要求,视图不好:(
   calendar.init(lastYear.getTime(), nextYear.getTime()) //
            .inMode(CalendarPickerView.SelectionMode.RANGE)
            .withSelectedDate(new Date())
 // deactivates given dates, non selectable
            .withDeactivateDates(list)
 // highlight dates in red color, mean they are aleady used.
            .withHighlightedDates(arrayList)
// add subtitles to the dates pass a arrayList of SubTitle objects with date and text
            .withSubtitles(getSubtitle())