How to set SwipeRefreshLayout refreshing property using android data binding?

No need to hack. The key is to look for the public methods in SwipeRefreshLayout documentation. In general, Databinding will look for the corresponding name without the set part. E.g. you’ll find there: setOnRefreshListener(SwipeRefreshLayout.OnRefreshListener listener) setRefreshing(boolean refreshing) The OnRefreshListener Since OnRefreshListener is a public interface, with a single method, you can directly use this in … Read more

Android: CoordinatorLayout and SwipeRefreshLayout

Set the scroll behavior to the SwipeRefreshLayout not the RecyclerView. <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id=”@+id/swipe_container” android:layout_width=”match_parent” android:layout_height=”match_parent” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <androidx.recyclerview.widget.RecyclerView android:id=”@+id/cardList” android:layout_width=”match_parent” android:layout_height=”match_parent” android:scrollbars=”vertical” /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

HorizontalScrollView inside SwipeRefreshLayout

I solved it by extending SwipeRefreshLayout and overriding its onInterceptTouchEvent. Inside, I calculate if the X distance the user has wandered is bigger than the touch slop. If it does, it means the user is swiping horizontally, therefor I return false which lets the child view (the HorizontalScrollView in this case) to get the touch … Read more

RecyclerView and SwipeRefreshLayout

write the following code in addOnScrollListener of the RecyclerView Like this: recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){ @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int topRowVerticalPosition = (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop(); swipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0); } @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } });

Android: CollapsingToolbarLayout and SwipeRefreshLayout get stuck

Update: This issue has been resolved in the latest version of the support library (23.1.1+). If you are using an older version of the support library either upgrade or continue reading. If you’re using an older version of the support library, add an offset change listener to your AppBarLayout to enable or disable your swipe … Read more

SwipeRefreshLayout trigger programmatically

if you are using the new swipeRefreshLayout intoduced in 5.0 As the image shown above you just need to add the following line to trigger the swipe refresh layout programmatically Work in Java: mSwipeRefreshLayout.post(new Runnable() { @Override public void run() { mSwipeRefreshLayout.setRefreshing(true); } }); on in Kotlin: mSwipeRefreshLayout.post { mSwipeRefreshLayout.isRefreshing = true } NOT work … Read more

When switch fragment with SwipeRefreshLayout during refreshing, fragment freezes but actually still work

Well… After some struggling I eventually solved this problem by myself, in a tricky way… I just need to add these in onPause() : @Override public void onPause() { super.onPause(); … if (mSwipeRefreshLayout!=null) { mSwipeRefreshLayout.setRefreshing(false); mSwipeRefreshLayout.destroyDrawingCache(); mSwipeRefreshLayout.clearAnimation(); } }