detect View Right Edge - Android User Interface

Android examples for User Interface:View Margin

Description

detect View Right Edge

Demo Code


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

public class Main {
    public static final boolean detectRightEdge(View view) {
        if ((view == null) || (view.getVisibility() != 0)) {
            return false;
        }/*from  ww  w. java  2s  .  co  m*/
        if ((view instanceof AdapterView)) {
            return c((AdapterView) view);
        }
        return view.getScrollX() + view.getMeasuredWidth() >= view
                .getRight();
    }

    private static boolean c(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.getRight() <= paramAdapterView.getRight();
            }
        }
        return false;
    }
}

Related Tutorials