detect View Left Edge - Android User Interface

Android examples for User Interface:View Margin

Description

detect View Left Edge

Demo Code


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

public class Main {
    public static final boolean detectLeftEdge(View view) {
        if ((view == null) || (view.getVisibility() != 0)) {
            return false;
        }//from  ww  w . jav  a 2 s.  c  om
        if ((view instanceof AdapterView)) {
            return b((AdapterView) view);
        }

        return view.getScrollX() >= 0;
    }

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

Related Tutorials