turing-tech / MaterialScrollBar

An Android library that brings the Material Design 5.1 sidebar to pre-5.1 devices.
Apache License 2.0
778 stars 126 forks source link

RecyclerView in SwipeRefreshLayout Scroll doesn't show #9

Closed andanicalik closed 8 years ago

andanicalik commented 9 years ago

When my recyclerview in swiperefreshlayout scroll doesn't show. What can i do for solve ?

turing-tech commented 9 years ago

I'll look at the issue today when I get home (~15:00 UTC -8)

Tolriq commented 9 years ago

Just started to test this library and get into this problem too.

Seems related to having the recyclerview in a FrameLayout. Switching to a RelativeLayout fixed it, but support for FrameLayout would be better for performance and maybe there's impact too with CoordinatorLayout (Not tested yet).

turing-tech commented 9 years ago

The issue is that I can't put the scrollBar in there because it's a view of its own and obviously can't coexist with the recyclerView in a layout that only supports one child. The solution at the moment would be to wrap the recyclerView in a relativeLayout, which will work, though it is inelegant. I'll work on coming up with a better solution to support a wider variety of parent views since it's pretty limited atm.

Tolriq commented 9 years ago

Well after reading again the issue, mine is different :)

FrameLayout support multiple childs and the bar is visible it's just at left instead of right.

MFlisar commented 9 years ago

The solution with wrapping the content of the SwipeRefreshLayout in a container works, but somehow this is disturbing the SwipeRefreshLayout...

When I scroll up, everything works, but when i scroll down, it shows the refreshing view even if I'm not scrolled up and I can't scroll up anymore...

I'm quite sure the SwipeRefreshLayout depends on it's one child scrolling behaviour and that's the source reason this is not working correctly

samy-baili commented 8 years ago

That's works for me :

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/reveal_notification">

    <RelativeLayout
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">

         <android.support.v7.widget.RecyclerView
              android:id="@+id/recycler_view"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:fadeScrollbars="true"
              android:paddingTop="5dp"
              android:paddingBottom="5dp"
              android:background="@color/search_bar"/>
    </RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>

AND

mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
     @Override
     public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
           if (linearLayoutManager.findFirstCompletelyVisibleItemPosition() == 0)
                 mSwipeRefreshLayout.setEnabled(true);
            else
                 mSwipeRefreshLayout.setEnabled(false);
      }
});
Rainer-Lang commented 8 years ago

Same issue here.

samy-baili commented 8 years ago

Did you try my solution above ?

Rainer-Lang commented 8 years ago

@samy-baili Yes - this saved me. :+1: But I'm hoping that this could be handled in the lib.