Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeRefreshLayout not working when first item has a height of 0

SwipeRefreshLayout does not work (animation not shown, onRefresh not called) when the first item in the RecyclerView within the SwipeRefreshLayout has a height of zero.

You can check out a test project on Github that shows this.

My question is: can this effect be circumvented? In my actual project, due to circumstances not in my hand (Ad library)the first item of my list will sometimes have a height of 0, so setting it to View.GONE or height to 1 is not an option.

like image 730
fweigl Avatar asked Nov 24 '16 13:11

fweigl


1 Answers

Found an workaround: Put RecyclerView to into additional view:

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

it cause additional overdraw, but works

few more suggestions found here: https://github.com/airbnb/epoxy/issues/74

like image 114
Siarhei Avatar answered Oct 13 '22 21:10

Siarhei