首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MaterialCalendarView打开速度慢

MaterialCalendarView打开速度慢
EN

Stack Overflow用户
提问于 2015-07-22 17:28:23
回答 2查看 1.1K关注 0票数 8

我在我的应用中使用MaterialCalendarView (https://github.com/prolificinteractive/material-calendarview)。它就在我的一个片段里。当我打开这个片段时,它需要大约2秒的时间加载-我可以看到屏幕延迟。这真的很烦人。我一直在到处搜索,发现这是CalendarView的已知问题,我一直在尝试各种修复方法:将它放入FrameLayout中,将layout_height设置为match_parent,将layout_height设置为固定高度,甚至将视图放入新的xml布局文件中,但似乎对这个自定义小部件都无效。其他人对这个小工具有什么问题吗?

这是我的布局代码:

代码语言:javascript
复制
<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>
EN

回答 2

Stack Overflow用户

发布于 2017-11-22 15:35:15

我希望你是在谈论正在设定的当前日期的动摇。为了克服这个问题,只需添加以下几行代码:

代码语言:javascript
复制
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);

你的抖动就会停止。

票数 4
EN

Stack Overflow用户

发布于 2016-11-12 00:59:17

只显示了几个月。使用setMinDate()setMaxDate()方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31559154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档