SmartRefreshLayout icon indicating copy to clipboard operation
SmartRefreshLayout copied to clipboard

数据量多的时候,material 下拉刷新会很难拉下来

Open fox0830 opened this issue 2 years ago • 3 comments

数据量多的时候,也就是recycleview很长的时候,material 的下拉刷新会很难拉下来,只能拉下来一点点,而且无法触发刷新

fox0830 avatar Jun 09 '23 02:06 fox0830

NestedScrollView 嵌套 SmartRefreshLayout时才会有这种情况

fox0830 avatar Jun 09 '23 03:06 fox0830

NestedScrollView 嵌套 SmartRefreshLayout时才会有这种情况

后续,我改成了把整个NestedScrollView包裹在了SmartRefreshLayout里面,不过这样一来,刷新头会从NestedScrollView顶部出现,而不是从RecycleView顶部出现了。

fox0830 avatar Jun 09 '23 04:06 fox0830

数据量多的时候,也就是recycleview很长的时候,material 的下拉刷新会很难拉下来,只能拉下来一点点,而且无法触发刷新 onMeasure()方法结尾加上以下内容

        if (useAutoChangeMaxDrag) {
            if (getHeight() != 0 && allHeight == 0) {
                allHeight = getHeight();
            } else if (allHeight != 0 && getHeight() != 0) {
                this.mHeaderMaxDragRate = getHeight() / (allHeight * .6F);
            }
        }
protected float MAX_DRAG_RATE = 10;//mHeaderMaxDragRate < 10    -->"10"用 MAX_DRAG_RATE替换
private boolean useAutoChangeMaxDrag = false;
private int allHeight = 0;

/**
 * 为了解决外层嵌套 NestedScrollView 时,RecyclerView内容过多而导致的下拉刷新困难
 * 没有测试其他情况的兼容冲突,所以需要手动调用 removeMaxDragRateLimit()以避免对其他已有正常逻辑的影响
 */
public void removeMaxDragRateLimit() {
    this.useAutoChangeMaxDrag = true;
    this.MAX_DRAG_RATE = 100F;
}

raoqian156 avatar Jul 19 '23 03:07 raoqian156