I have a ListView, first its scrolled down, now when we scroll up,it reach top most point. I want to detect that .Is there any way?I am developing application with api level
Graeme's answer is close but is missing something that user2036198 added, a check for getFirstVisiblePosition(). getChildAt(0) doesn't return the very first view for the very first item in the list. AbsListView implementations don't make a single view for every position and keep them all in memory. Instead, view recycling takes effect to limit the number of views instantiated at any one time.
The fix is pretty simple:
public boolean canScrollVertically(AbsListView view) {
boolean canScroll = false;
if (view != null && view.getChildCount() > 0) {
// First item can be partially visible, top must be 0 for the item
canScroll = view.getFirstVisiblePosition() != 0 || view.getChildAt(0).getTop() != 0;
}
return canScroll;
}
For best results on ICS or higher, always use ViewCompat from the v4 support library or View.canScrollVertically(). Use the above method on lower API levels as ViewCompat always returns false for canScrollVertically() and canScrollHorizontally() below ICS.