Example usage for android.view ViewGroup getLeft

List of usage examples for android.view ViewGroup getLeft

Introduction

In this page you can find the example usage for android.view ViewGroup getLeft.

Prototype

@ViewDebug.CapturedViewProperty
public final int getLeft() 

Source Link

Document

Left position of this view relative to its parent.

Usage

From source file:example.luojing.androidsourceanalysis.ViewPager.java

/**
 * ViewPager????View??/*from  ww  w. ja  v a2s  .  c  o  m*/
 */
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) {
    if (outRect == null) {
        outRect = new Rect();
    }
    if (child == null) {
        outRect.set(0, 0, 0, 0);
        return outRect;
    }
    outRect.left = child.getLeft();
    outRect.right = child.getRight();
    outRect.top = child.getTop();
    outRect.bottom = child.getBottom();

    ViewParent parent = child.getParent();
    while (parent instanceof ViewGroup && parent != this) {
        final ViewGroup group = (ViewGroup) parent;
        outRect.left += group.getLeft();
        outRect.right += group.getRight();
        outRect.top += group.getTop();
        outRect.bottom += group.getBottom();

        parent = group.getParent();
    }
    return outRect;
}