我在我的应用中使用MaterialCalendarView (https://github.com/prolificinteractive/material-calendarview)。它就在我的一个片段里。当我打开这个片段时,它需要大约2秒的时间加载-我可以看到屏幕延迟。这真的很烦人。我一直在到处搜索,发现这是CalendarView的已知问题,我一直在尝试各种修复方法:将它放入FrameLayout中,将layout_height设置为match_parent,将layout_height设置为固定高度,甚至将视图放入新的xml布局文件中,但似乎对这个自定义小部件都无效。其他人对这个小工具有什么问题吗?
这是我的布局代码:
<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>发布于 2017-11-22 15:35:15
我希望你是在谈论正在设定的当前日期的动摇。为了克服这个问题,只需添加以下几行代码:
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);你的抖动就会停止。
发布于 2016-11-12 00:59:17
只显示了几个月。使用setMinDate()和setMaxDate()方法。
https://stackoverflow.com/questions/31559154
复制相似问题