ListView determines whether the ListView has reached the bottom and top
The judgment that the ListView has reached the top
public boolean isListViewReachTopEdge(final ListView listView) { boolean result=false; if(listView.getFirstVisiblePosition()==0){ final View topChildView = listView.getChildAt(0); result=topChildView.getTop()==0; } return result ; }Note:GetTop () of a view indicates the vertical distance from the top of the View to the upper left corner of the parent control. When the getTop () value of the first child View in ListView is zero, it indicates that the ListView has been rolled to the top or cannot be moved up on the top.
The judgment that the ListView has reached the bottom
public boolean isListViewReachBottomEdge(final ListView listView) { boolean result=false; if (listView.getLastVisiblePosition() == (listView.getCount() - 1)) { final View bottomChildView = listView.getChildAt(listView.getLastVisiblePosition() - listView.getFirstVisiblePosition()); result= (listView.getHeight()>=bottomChildView.getBottom()); }; return result; }Note:The getBottom () of the view indicates the vertical distance from the bottom of the View to the upper left corner of the parent control. When the getBottom () of the last child View of the ListView is smaller than or equal to the getHeight () of the ListView, it indicates that the ListView is rolled to the bottom or already at the bottom. You cannot slide down any more. For more information about getLeft, getRight, getTop, and getBottom of View, see getLeft, getRight, getTop, and getBottom of Android View.