detect View Bottom Edge - Android User Interface

Android examples for User Interface:View Margin

Description

detect View Bottom Edge

Demo Code


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

public class Main {
    public static final boolean detectBottomEdge(View view) {
        if ((view == null) || (view.getVisibility() != 0)) {
            return false;
        }/*from   ww w .  j  a  v a2  s .  c  o  m*/
        if ((view instanceof AdapterView)) {
            return d((AdapterView) view);
        }
        return view.getScrollY() + view.getMeasuredHeight() >= view
                .getBottom();
    }

    private static boolean d(AdapterView paramAdapterView) {
        int i = paramAdapterView.getCount();
        int j = paramAdapterView.getLastVisiblePosition();
        if (i == 0) {
            return true;
        }
        if (j == i - 1) {
            int k = j - paramAdapterView.getFirstVisiblePosition();
            View localView = paramAdapterView.getChildAt(k);
            if (localView != null) {
                return localView.getBottom() <= paramAdapterView
                        .getBottom();
            }
        }
        return false;
    }
}

Related Tutorials