public boolean canScrollListDown() { // Ported from AbsListView#canScrollList() which isn't compatible to all API levels final int childCount = mView.getChildCount(); final int itemsCount = mView.getCount(); final int firstPosition = mView.getFirstVisiblePosition(); final int lastPosition = firstPosition + childCount; final int lastBottom = mView.getChildAt(childCount - 1).getBottom(); return lastPosition < itemsCount || lastBottom > mView.getHeight() - mView.getListPaddingBottom(); } }
private boolean listIsAtBottom(){ return listView.getChildAt(listView.getChildCount()-1).getBottom() + paddingRectangle.bottom == listView.getHeight(); }
public abstract class OnScrollPositionChangedListener implements AbsListView.OnScrollListener { int pos; public int viewHeight = 0; public int listHeight = 0; @Override public void onScroll(AbsListView v, int i, int vi, int n) { try { if(viewHeight==0) { viewHeight = v.getChildAt(0).getHeight(); listHeight = v.getHeight(); } pos = viewHeight * i; } catch (Exception e) { e.printStackTrace(); } finally { onScrollPositionChanged(pos); } } @Override public void onScrollStateChanged(AbsListView absListView, int i) {} public abstract void onScrollPositionChanged(int scrollYPosition); }
private boolean canScrollListDown() { // Ported from AbsListView#canScrollList() which isn't compatible to all API levels final int childCount = mView.getChildCount(); final int itemsCount = mView.getCount(); final int firstPosition = mView.getFirstVisiblePosition(); final int lastPosition = firstPosition + childCount; final int lastBottom = mView.getChildAt(childCount - 1).getBottom(); return lastPosition < itemsCount || lastBottom > mView.getHeight() - mView.getListPaddingBottom(); } }
public boolean isListViewReachBottomEdge(final AbsListView 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; }
isLatestEventDisplayed = (null != childView) && ((childView.getTop() + childView.getHeight()) <= view.getHeight());
yourListView.setOnScrollListener(this); @Override public void onScroll(AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount) { int vH = view.getHeight(); int topPos = view.getChildAt(0).getTop(); int bottomPos = view.getChildAt(visibleItemCount - 1).getBottom(); switch(view.getId()) { case R.id.your_list_view_id: if(firstVisibleItem == 0 && topPos == 0) { //TODO things to do when the list view scroll to the top } if(firstVisibleItem + visibleItemCount == totalItemCount && vH >= bottomPos) { //TODO things to do when the list view scroll to the bottom } break; } }
/** * Returns, whether a specific list view is scrolled to the bottom, or not. * * @param scrollView * The list view as an instance of the class {@link AbsListView}. The list view may not * be null * @return True, if the given list view is scrolled to the bottom, false otherwise */ private boolean isListViewScrolledToBottom(@NonNull final AbsListView scrollView) { if (scrollView.getCount() > 0 && scrollView.getChildCount() > 0) { if (scrollView.getLastVisiblePosition() == scrollView.getCount() - 1) { View child = scrollView.getChildAt(scrollView.getChildCount() - 1); return child == null || child.getBottom() <= scrollView.getHeight(); } } else { return true; } return false; }
/** */ @Override public boolean isScrolledAtEnd() { final int childCount = mScrollableView.getChildCount(); if (childCount == 0) { return true; } final Adapter adapter = mScrollableView.getAdapter(); final int adapterCount = adapter != null ? adapter.getCount() : 0; if (adapterCount == 0) { return true; } final int lastVisiblePos = mScrollableView.getLastVisiblePosition(); if (lastVisiblePos == (adapterCount - 1)) { final View lastChild = mScrollableView.getChildAt(childCount - 1); return lastChild != null && lastChild.getBottom() == mScrollableView.getHeight(); } return false; } }
/** */ @Override public boolean isScrolledAtEnd() { final int childCount = mScrollableView.getChildCount(); if (childCount == 0) { return true; } final Adapter adapter = mScrollableView.getAdapter(); final int adapterCount = adapter != null ? adapter.getCount() : 0; if (adapterCount == 0) { return true; } final int lastVisiblePos = mScrollableView.getLastVisiblePosition(); if (lastVisiblePos == (adapterCount - 1)) { final View lastChild = mScrollableView.getChildAt(childCount - 1); return lastChild != null && lastChild.getBottom() == mScrollableView.getHeight(); } return false; } }
/** */ @Override public boolean isScrolledAtEnd() { final int childCount = mScrollableView.getChildCount(); if (childCount == 0) { return true; } final Adapter adapter = mScrollableView.getAdapter(); final int adapterCount = adapter != null ? adapter.getCount() : 0; if (adapterCount == 0) { return true; } final int lastVisiblePos = mScrollableView.getLastVisiblePosition(); if (lastVisiblePos == (adapterCount - 1)) { final View lastChild = mScrollableView.getChildAt(childCount - 1); return lastChild != null && lastChild.getBottom() == mScrollableView.getHeight(); } return false; } }
/** * Copy From AbsListView (API Level >= 19) * @param absListView AbsListView * @param direction Positive to check scrolling up, negative to check * scrolling down. * @return true if the list can be scrolled in the specified direction, * false otherwise */ private boolean absListViewCanScrollList(AbsListView absListView,int direction) { final int childCount = absListView.getChildCount(); if (childCount == 0) { return false; } final int firstPosition = absListView.getFirstVisiblePosition(); if (direction > 0) {//can scroll down final int lastBottom = absListView.getChildAt(childCount - 1).getBottom(); final int lastPosition = firstPosition + childCount; return lastPosition < absListView.getCount() || lastBottom > absListView.getHeight() - absListView.getPaddingTop(); } else {//can scroll up final int firstTop = absListView.getChildAt(0).getTop(); return firstPosition > 0 || firstTop < absListView.getPaddingTop(); } }
ScrollLocation mNewScrollLocation; final int gridTop = view.getPaddingTop(); final int gridBottom = view.getHeight() - view.getPaddingBottom(); if (totalItemCount == visibleItemCount) {
if (lastVisibleItemView != null && lastVisibleItemView.getBottom() <= listView.getHeight()) { return true;
private boolean canScrollList(@ScrollOrientation int direction, AbsListView listView) { final int childCount = listView.getChildCount(); if (childCount == 0) { return false; } final int firstPos = listView.getFirstVisiblePosition(); final int paddingBottom = listView.getListPaddingBottom(); final int paddingTop = listView.getListPaddingTop(); if (direction > 0) { final int lastBottom = listView.getChildAt(childCount - 1).getBottom(); final int lastPos = firstPos + childCount; return lastPos < listView.getChildCount() || lastBottom > listView.getHeight() - paddingBottom; } else { final int firstTop = listView.getChildAt(0).getTop(); return firstPos > 0 || firstTop < paddingTop; } }
public void run() { final int listHeight = mList.getHeight(); final int firstPos = mList.getFirstVisiblePosition();