dinuscxj/RecyclerRefreshLayout

我下拉刷新时 textview会闪一下,但是imageview就没事 是什么原因

Closed this issue · 3 comments

请问 博主有遇到过吗

@YongshengLuan 我也遇到了
原因应该是你的textview宽度设置为wrap_content,当调用setText时导致重新layout,而RecyclerRefreshLayout的onlayout实现是把refreshView和TargetView布局到原始的位置,所以会出现闪烁的现象,解决办法有两个:
1、textview宽度设置为固定宽度
2、从根源上解决问题,RecyclerRefreshLayout的onlayout的实现改为:

    if (getChildCount() == 0) {
        return;
    }

    ensureTarget();
    if (mTarget == null) {
        return;
    }

    final int width = getMeasuredWidth();
    final int height = getMeasuredHeight();
    final int childTop = getPaddingTop();
    final int childLeft = getPaddingLeft();
    final int childWidth = width - getPaddingLeft() - getPaddingRight();
    final int childHeight = height - getPaddingTop() - getPaddingBottom();

    int targetTop, refreshViewTop;
    switch (mRefreshStyle) {
        case FLOAT:
            refreshViewTop = (int) mTargetOrRefreshViewOffsetY;
            targetTop = childTop;
            break;
        case PINNED:
            refreshViewTop = (int) mRefreshInitialOffset;
            targetTop = (int) mTargetOrRefreshViewOffsetY;
            break;
        default:
            refreshViewTop = (int) (mRefreshInitialOffset + mTargetOrRefreshViewOffsetY);
            targetTop = (int) (childTop + mTargetOrRefreshViewOffsetY);
            break;
    }

    mTarget.layout(childLeft, targetTop, childLeft + childWidth, targetTop + childHeight);

    mRefreshView.layout((width / 2 - mRefreshView.getMeasuredWidth() / 2), refreshViewTop,
            (width / 2 + mRefreshView.getMeasuredWidth() / 2), refreshViewTop + mRefreshView.getMeasuredHeight());

以上实现我只在default样式测试过,其他样式你看对不对

好的我试试 谢谢啦

fix 3e6a553 and release 2.0.5