Zhao-Yan-Yan/MultiStatePage

使用自动刷新框架SmartRefreshLayout 时,bindMultiState(recyclerView),布局显示异常

Closed this issue · 9 comments

<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/srl_refresh"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/cl_toolbar"
app:layout_constraintBottom_toBottomOf="parent">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/app_dp_9"
        android:background="@color/app_ffd2d0"
        android:overScrollMode="never"/>

</com.scwang.smart.refresh.layout.SmartRefreshLayout>

我也遇到这个问题了,使用在recycleview上不能显示,用在SmartRefreshLayout就不能刷新了

是的 确实有问题

麻烦作者修复下吧

这个问题是SmartRefreshLayout的机制导致的,onFinishInflate 里面获取 RecyclerView 保存下来,这个只会在xml布局完成调用,当布局完成时重新替换布局不会再次触发,当再次调用addView的时候,那么onLayout mRefreshContent.getView() == child
这句代码就为false,就不会为内容布局重新执行布局,解决起来也很简单,外面再嵌套一层布局,不过缺点就是,statePage 外面自动嵌套一层,再嵌套一层,嵌套过多了

@wvisible 大哥有想法可以提一下 我最近实在太忙了现在还在加班

我的意思是在布局的时候直接对 RecyclerView 外面包裹一层就能解决问题,因为从 MultiStatePage 的实现来看,父布局各种各样,有的不支持 addView,那么这种就会出现问题,暂时解决方案只能外面嵌套一层,暂时还没想到好的解决方法

现在改成可以在xml里面直接用了 暂时没有找到更好的办法

Ye83 commented

有解决的demo 吗

Ye83 commented

@wvisible 怎么在外面加一层