Search code examples
androidandroid-layoutandroid-4.4-kitkatswiperefreshlayout

SwipeRefreshLayout progress drawable doesn't hide completely on KitKat


I have something like this:

<ConstraintLayout>
    <SwipeRefreshLayout>
        <RecyclerView>

Constraint also has a animateLayoutChanges = "true" But I'm sure it's not a cause.

When I do swipe-to-refresh gesture - it's okay, everything works fine, progress hides as it should. But if I swipe down, then, without releasing my finger, I swipe up to hide the progress drawable, part of it remains visible.

Appears only on 4.4 and below.

enter image description here


Solution

  • Actionbar could got thinner when orientation changes or you have set actionbar size manually. Set the offset in pixels from the top of the view at which the progress spinner should come to reset after a successful swipe gesture to the current actionbar size.

    TypedValue typedValue = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.support.v7.appcompat.R.attr.actionBarSize, typedValue, true);
    mSwipeRefreshLayout.setProgressViewOffset(false, 0, getResources().getDimensionPixelSize(typedValue.resourceId));
    

    Solution is taken from an answer to a different question about: swipeRefreshLayout

    Test if this helps you first: mSwipeRefreshLayout.setProgressViewOffset(false, 0, 64) or maybe a little bigger than 64