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?