Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SwipeRefreshLayout停止工作/RecyclerView不一致地触发SwipeRefreshLayout_Android_Android Recyclerview_Android Support Library_Swiperefreshlayout - Fatal编程技术网

Android SwipeRefreshLayout停止工作/RecyclerView不一致地触发SwipeRefreshLayout

Android SwipeRefreshLayout停止工作/RecyclerView不一致地触发SwipeRefreshLayout,android,android-recyclerview,android-support-library,swiperefreshlayout,Android,Android Recyclerview,Android Support Library,Swiperefreshlayout,我发现在Nexus 6P API 25 7.1.1模拟器上,RecyclerView不一致地激活SwiperFreshLayout存在问题。 我们正在使用最新版本的支持库: compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:design:25.3.1' compile 'com.and

我发现在Nexus 6P API 25 7.1.1模拟器上,RecyclerView不一致地激活SwiperFreshLayout存在问题。 我们正在使用最新版本的支持库:

compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
我有一个RecyclerView,其中包含一个数据集,在拉入刷新发生时(将项目添加到顶部),它在我的布局中声明如下:

<android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeRefresh"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true" />
</android.support.v4.widget.SwipeRefreshLayout>

视图
中,计算
的代码可以垂直滚动(-1)
取决于
计算垂直滚动偏移量
计算垂直滚动范围
计算垂直滚动范围
的结果

RecyclerView
依赖于
LinearLayoutManager
进行这些计算。如果
smoothScrollbarEnabled
true
(默认值),则会转发到
ScrollbarHelper
,该助手会执行一些近似操作,以显示一个奇特的滚动条

如果
RecyclerView
中的项目大小不同,则这些近似值将完全错误

LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setSmoothScrollbarEnabled(false);
recyclerView.setLayoutManager(llm);
解决了我们的问题,并使
SwipeRefreshLayout
在每次我们到达列表顶部时可靠地触发

LinearLayoutManager llm = new LinearLayoutManager(getActivity());
llm.setSmoothScrollbarEnabled(false);
recyclerView.setLayoutManager(llm);