What is this blue shadow called?
Asked Answered
A

2

7

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.

Assr answered 11/2, 2015 at 8:40 Comment(0)
C
6

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.

Cecum answered 11/2, 2015 at 8:46 Comment(5)
I want it for viewgroup.. what to do?Assr
developer.android.com/reference/android/widget/AbsListView.html Also check this out developer.android.com/training/gestures/scroll.htmlCecum
For that check out the pull to refresh library!Cecum
it does not work....tried everything...even implemented an on scroll listener which fails in some cases.Assr
your answer did not help but it gave me an idea on how to achieve my requirement.So accepting it.Thanks a lot.Assr
S
3

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 ...
      }
}
Seed answered 11/2, 2015 at 11:28 Comment(1)
I achived it using goonerdroid's idea...thnx a lot for your help.I have this swipe refresh layout to refresh the view.Assr

© 2022 - 2024 — McMap. All rights reserved.