check if View Can Pull Down - Android User Interface

Android examples for User Interface:View

Description

check if View Can Pull Down

Demo Code


//package com.java2s;
import android.view.View;
import android.widget.AbsListView;

public class Main {
    public static boolean checkCanPullDown(View view) {
        return !canChildScrollUp(view);
    }/*from w ww .ja va  2 s .c  om*/

    public static boolean canChildScrollUp(View view) {
        if (android.os.Build.VERSION.SDK_INT < 14) {
            if (view instanceof AbsListView) {
                final AbsListView absListView = (AbsListView) view;
                return absListView.getChildCount() > 0
                        && (absListView.getFirstVisiblePosition() > 0 || absListView
                                .getChildAt(0).getTop() < absListView
                                .getPaddingTop());
            } else {
                return view.getScrollY() > 0;
            }
        } else {
            return view.canScrollVertically(-1);
        }
    }
}

Related Tutorials