Android 当RecyclerView有一个以上的项目时,PullRefreshLayout将闪烁并冻结,然后屏幕将显示

Android 当RecyclerView有一个以上的项目时,PullRefreshLayout将闪烁并冻结,然后屏幕将显示,android,material-design,android-coordinatorlayout,android-collapsingtoolbarlayout,Android,Material Design,Android Coordinatorlayout,Android Collapsingtoolbarlayout,我对pullrefresh布局动画有一些问题。 问题是,只有当适配器中的项多于屏幕适合项时,此问题才与相关 我想强调的是,如果我在列表中再添加一个项目,或者删除一个项目pullDownToFerfesh效果很好。 你可以看到这一点 更新: 我检查了UI线程中是否可以执行任何任务,并对所有回调和已分析的UI线程进行了注释,发现只有一个操作需要时间:Handler.dispatchMessage。根本没有对我的代码进行大量调用。 这是我的布局: <android.support.desi

我对pullrefresh布局动画有一些问题。 问题是,只有当适配器中的项多于屏幕适合项时,此问题才与相关

我想强调的是,如果我在列表中再添加一个项目,或者删除一个项目pullDownToFerfesh效果很好。 你可以看到这一点

更新:

我检查了UI线程中是否可以执行任何任务,并对所有回调和已分析的UI线程进行了注释,发现只有一个操作需要时间:Handler.dispatchMessage。根本没有对我的代码进行大量调用。 这是我的布局:

   <android.support.design.widget.CoordinatorLayout
    android:id="@+id/tabs_coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/app_bar_layout">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/tabs_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:elevation="0dp"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp"
        app:layout_behavior="com.timyo.andapp.ui.utils.AppBarLayoutBehavior">

         <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/tabsToolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:contentInsetStart="0dp"
            android:theme="@style/AppTheme.Toolbar"
            app:contentInsetStart="0dp"
            app:layout_scrollFlags="scroll|enterAlways|snap"
            app:popupTheme="@style/AppTheme.PopupOverlay">

            <android.support.design.widget.TabLayout
                android:id="@+id/tabLayout"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:tabGravity="fill"
                app:tabIndicatorHeight="@dimen/tab_indicator_height"
                app:tabMaxWidth="0dp"
                app:tabMode="fixed"
                app:tabPaddingEnd="@dimen/tab_padding"
                app:tabPaddingStart="@dimen/tab_padding" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <RelativeLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipe_refresh_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/messages_recycler"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

             </android.support.v4.widget.SwipeRefreshLayout>

    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>

如果您在这里有代码,那将非常有用,但我想我在您的xml中发现了一些东西



android.support.v4.widget.swiperFreshLayout的结束标记错误

我很可能解决了这个问题。所以,问题在于滚动工具栏行为和滑动以刷新布局。因为一旦我删除了
滚动标记(仅用于测试),动画就可以正常工作了

我找到了解决办法。因此,我首先在
CoordinatorLayout
中放置了带有内容布局的
NestedScrollView
,然后在
TableLayout
中放置了
AppBarLayout
,动画开始正常工作


我还不清楚为什么它只与项目的确切数量有关,可能有一些东西与
interceptTouchEvent/onTouchEvent
调用有关。

发布一些代码。你能在这里粘贴代码吗?我的猜测是,如果屏幕冻结,很可能您正在执行一些IO操作或一些在UI线程上花费时间的逻辑。一般来说,将这些任务转移到另一个线程中,并在完成后更新UI。感谢各位的回答@hjchin很好,我更新了我的问题,但确实发现在UI线程中执行了任何繁重的任务。似乎是
折叠工具栏
下拉刷新
布局结构之间存在冲突,我只是在复制时错过了这个关闭标签。不,我是说你有一个上面的标签,我知道了,谢谢。我在帖子中编辑了代码片段。
        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipe_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/messages_recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

</RelativeLayout>