Slow Opening MaterialCalendarView

I am using MaterialCalendarView ( https://github.com/prolificinteractive/material-calendarview ) in my application. It is inside one of my fragments. When I open this fragment, the download takes about 2 seconds - I can observe the screen delay. This is very annoying. I searched and found out that this is a known issue for CalendarView and I am trying to make various corrections: put it in FrameLayout, set layout_height to match_parent, set layout_height to a fixed height, even put the view in a new xml layout file, but nothing seems to work for this custom widget. Has anyone else had problems with this widget?

Here is my layout code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="net.matto.android.schoolplanner.fragment.CalendarFragment"> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2"> <com.prolificinteractive.materialcalendarview.MaterialCalendarView android:id="@+id/calendar_view" android:layout_width="match_parent" android:layout_height="match_parent" app:mcv_selectionColor="@color/primary_dark" app:mcv_firstDayOfWeek="monday"/> </FrameLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <android.support.v7.widget.RecyclerView android:id="@+id/recyclerview_events" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- empty list --> <TextView android:id="@+id/recyclerview_events_empty" android:text="@string/no_events" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingEnd="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingStart="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" /> <android.support.design.widget.FloatingActionButton android:id="@+id/add_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_marginBottom="@dimen/fab_margin_bottom" android:layout_marginRight="@dimen/fab_margin_right" android:layout_marginEnd="@dimen/fab_margin_right" app:borderWidth="0dp" android:src="@drawable/ic_plus" app:fabSize="normal" /> </FrameLayout> </LinearLayout> 
+5
source share
2 answers

Hope you are talking about shaking the current date that is set. To overcome this problem, simply add the following lines of code:

 calendarView = (MaterialCalendarView) view.findViewById(R.id.calendarView); calendarView.setSelectionMode(MaterialCalendarView.SELECTION_MODE_SINGLE); new Handler().postDelayed(new Runnable() { @Override public void run() { calendarView.setSelectedDate(new Date()); } },1000); 

Your trembling will stop.

+1
source

Just show a few months. Use the setMinDate () and setMaxDate () methods.

0
source

All Articles