detect View Top Edge - Android User Interface

Android examples for User Interface:View Margin

Description

detect View Top Edge

Demo Code


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

public class Main {
    public static final boolean detectTopEdge(View view) {
        if ((view == null) || (view.getVisibility() != 0)) {
            return false;
        }/*from www  .  j  a v a2s .  c  o  m*/
        if ((view instanceof AdapterView)) {
            return a((AdapterView) view);
        }

        return view.getScrollY() >= 0;
    }

    private static boolean a(AdapterView paramAdapterView) {
        if (paramAdapterView.getCount() == 0) {
            return true;
        }
        if (paramAdapterView.getFirstVisiblePosition() == 0) {
            View localView = paramAdapterView.getChildAt(0);
            if (localView != null) {
                return localView.getTop() >= paramAdapterView.getTop();
            }
        }
        return false;
    }
}

Related Tutorials