I use the OrangeGangsters SwipyRefreshLayout and when the ListView scrolling didn’t work with the ListView scrolling, but it was triggered by SwipyRefreshLayout, that is, an update. I fixed this error:

listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { boolean enable = false; if (listView != null && listView.getChildCount() > 0) { boolean firstItemVisible = listView.getFirstVisiblePosition() == 0; boolean topOfFirstItemVisible = listView.getChildAt(0).getTop() == 0; enable = firstItemVisible && topOfFirstItemVisible ; } swipeRefreshLayout.setEnabled(enable); } }); 

Now the error on the contrary down does not work, SwipeRefreshLayout works;

XML:

 <?xml version="1.0" encoding="utf-8"?> 

 <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolBar" android:layout_width="match_parent" android:layout_height="?actionBarSize" android:background="@color/colorPrimary" app:titleTextAppearance="@style/Toolbar.TitleText"> <LinearLayout android:layout_width="wrap_content" android:layout_height="40dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="false" android:layout_alignParentStart="true" android:layout_gravity="right" android:orientation="horizontal" android:padding="@dimen/five_dp"> <TextView android:id="@+id/etOnline" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:text="В сети" android:textColor="@android:color/white" /> </LinearLayout> </android.support.v7.widget.Toolbar> <RelativeLayout android:id="@+id/offlineMessageRelative" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_below="@+id/toolBar" android:visibility="gone"> <RelativeLayout android:id="@+id/relative" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:background="@drawable/main_dark_bg" android:paddingBottom="@dimen/edit_text_padding" android:paddingLeft="@dimen/ten_dp" android:paddingRight="@dimen/ten_dp" android:paddingTop="@dimen/edit_text_padding"> <TextView android:id="@+id/message" android:layout_width="270dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:gravity="center_horizontal" android:text="@string/offline_message" android:textColor="@color/background_color_light" android:textSize="@dimen/mainLargeSize" /> </RelativeLayout> </RelativeLayout> <com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_below="@+id/toolBar" android:layout_height="wrap_content" app:srl_direction="both"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingLeft="@dimen/five_dp" android:paddingRight="@dimen/five_dp"> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@android:color/transparent" android:dividerHeight="@dimen/five_dp" android:drawSelectorOnTop="false" android:listSelector="@color/transparent_color" android:scrollbars="none" /> </LinearLayout> </com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout> <View android:id="@+id/line" android:layout_width="match_parent" android:layout_height="@dimen/three_dp" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentTop="false" android:layout_below="@+id/toolBar" android:background="@drawable/toolbars_shadow" /> <ImageView android:id="@+id/fab" android:layout_width="80dp" android:layout_height="80dp" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_gravity="bottom|end" android:background="@drawable/online_default" android:clickable="true" android:visibility="gone" /> </RelativeLayout> 

Tell me how to fix it?

  • it is not clear why you are building your crutches? The library works without them - Vladyslav Matviienko
  • The fact of the matter is that it works where the ListView needs to be scrolled, that is, you need to be updated only at the beginning where there is already nothing to scroll further and at the end ... And for me it works everywhere without allowing the ListView to scroll ... Scroll up I have already decided, now the scroll down is left ... - DevOma
  • show XML leyut file - Vladyslav Matviienko
  • Added, please check ... - DevOma

2 answers 2

You do not use it according to the instructions. Inside SwipyRefreshLayout should be a ListView , not LinearLayout . So it works for you wrong. So it should be:

 <com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout android:id="@+id/swipyrefreshlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" app:srl_direction="both"> <ListView android:id="@+id/listview" android:layout_width="match_parent" android:layout_height="match_parent" /> </com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout> 
  • The same problem did not help ... - DevOma

It is not very clear why the library is for this. You can just change the place the circle appears on the screen:

 //вверху int actionBarSize = ...; swipeRefreshLayout.setProgressViewEndTarget(false, actionBarSize); //внизу int screenHeight = ...; swipeRefreshLayout.setProgressViewEndTarget(false, screenHeight - actionBarSize * 2); //запускаем отображение //workaround from //http://stackoverflow.com/a/26910973/3212712 swipeRefreshLayout.post(new Runnable() { @Override public void run() { swipeRefreshLayout.setRefreshing(isLoading); } }); 

In general, SwipeRefreshLayout so buggy (and bugs in it are revived with every update) that it is better not to use it at all.

The latest adequate version of this widget is in versions 23.3.0 and 23.1.1. Versions before and in between - with bugs .

  • "You can just change the place of the circle on the screen." So that at the beginning and at the end there was an update on the scroll - DevOma
  • @Omuradil, In the beginning, the update is built in by default, and for the end, call the listener. For example - Yuriy SPb
  • In order to avoid all the perversions proposed by you, there is a library - Vladyslav Matviienko
  • @metalurgus, and all the bugs of the standard widget are corrected in it? .. It just seems doubtful to me all of whom there are fewer "likes" than a few thousand) - YuriySPb