L4Digital / FastScroll

A ListView-like FastScroller for Android’s RecyclerView.
Apache License 2.0
901 stars 75 forks source link

Unable to wrap FastScrollRecyclerView in a SwipeRefreshLayout #30

Closed ShawnTheBeachy closed 6 years ago

ShawnTheBeachy commented 6 years ago

In FastScroller.java, where it's checking the parent layout, SwipeRefreshLayout ought to be allowed so we can do pull to refresh.

ShawnTheBeachy commented 6 years ago

Actually, I guess there's no reason to not just put a FrameLayout inside the SwipeRefreshLayout, then put the recyclerview inside that.

randr0id commented 6 years ago

Also, SwipeRefreshLayout only supports one direct child and FastScrollRecyclerView requires support for sibling views (FastScroller and RecyclerView).

ShawnTheBeachy commented 6 years ago

@randr0id Good point! Additionally, putting the FastScrollRecyclerView inside a SwipeRefreshLayout makes it that you are unable to drag the handle; it just tries to refresh. In case anyone happens across this wanting to do the same thing, here's what I ended up doing:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipeLayout"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_height="match_parent"
        android:layout_width="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>

<com.l4digital.fastscroll.FastScroller
    android:id="@+id/fastScroller"
    android:layout_gravity="end"
    android:layout_height="match_parent"
    android:layout_marginBottom="16dp"
    android:layout_marginTop="16dp"
    android:layout_width="wrap_content" />

I then wired up the scroller manually as detailed in #4.