Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this blue shadow called?

What is this blue shadow called which apears when the view is pulled after it ends? is there a listener triggered when this appears or goes?

enter image description here

I have implemented https://github.com/maurycyw/StaggeredGridView and I want to load more items when this viewgroup is overscrolled.

like image 730
Rishabh Srivastava Avatar asked Feb 11 '15 08:02

Rishabh Srivastava


2 Answers

It is called as Overscroller.Listview has built-in support for overscrolling. Check out setOverscrollMode and related methods setOverscrollHeader and setOverscrollFooter. ListView makes use of the overscroll header/footer by overriding AbsListView.onOverscrolled; if you want different behavior, you can implement it by overriding it yourself.

like image 169
williamj949 Avatar answered Nov 03 '22 01:11

williamj949


unfortunately there's no ready library or functionality to achieve that. But there're good open library that you can adapt.

My suggestion is to check SwipeRefreshLayout, it's on the Android support library.

This ViewGroup support a swipe from the top to give a callback, you probably can adapt it to implement a bottom swipe.

docs: https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html

source code: https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v4/java/android/support/v4/widget/SwipeRefreshLayout.java

edit: alternatively, to implement a load more function with scroll listener is relatively easy, it's just a simple OnScrollListener with the following code:

private long lastRequestTime = 0;
public void onScroll (AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount){
      if (((firstVisibleItem+visibleItemCount) > totalItemCount - 4) &&
         (lastRequestTime + 1000 < System.currentTimeMillis())) {
         lastRequestTime = System.currentTimeMillis();
         // load more ...
      }
}
like image 27
Budius Avatar answered Nov 03 '22 02:11

Budius