Java Code Examples for android.view.View.getRight()

The following are Jave code examples for showing how to use getRight() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Hello-Music-droid   File: ViewDragHelper.java   View Source Code Vote up 7 votes
/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx     Delta scrolled in pixels along the X axis
 * @param dy     Delta scrolled in pixels along the Y axis
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
                    y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
                    canScroll(child, true, dx, dy, x + scrollX - child.getLeft(),
                            y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && (ViewCompat.canScrollHorizontally(v, -dx) ||
            ViewCompat.canScrollVertically(v, -dy));
}
 
Example 2
Project: FlycoTablayout   File: SegmentTabLayout.java   View Source Code Vote up 7 votes
private void calcOffset() {
        final View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
        mCurrentP.left = currentTabView.getLeft();
        mCurrentP.right = currentTabView.getRight();

        final View lastTabView = mTabsContainer.getChildAt(this.mLastTab);
        mLastP.left = lastTabView.getLeft();
        mLastP.right = lastTabView.getRight();

//        Log.d("AAA", "mLastP--->" + mLastP.left + "&" + mLastP.right);
//        Log.d("AAA", "mCurrentP--->" + mCurrentP.left + "&" + mCurrentP.right);
        if (mLastP.left == mCurrentP.left && mLastP.right == mCurrentP.right) {
            invalidate();
        } else {
            mValueAnimator.setObjectValues(mLastP, mCurrentP);
            if (mIndicatorBounceEnable) {
                mValueAnimator.setInterpolator(mInterpolator);
            }

            if (mIndicatorAnimDuration < 0) {
                mIndicatorAnimDuration = mIndicatorBounceEnable ? 500 : 250;
            }
            mValueAnimator.setDuration(mIndicatorAnimDuration);
            mValueAnimator.start();
        }
    }
 
Example 3
Project: OpenEyesReading-android   File: BaseLoginLayout1.java   View Source Code Vote up 7 votes
public void roundLoad(View myView) {
    int cx = (myView.getLeft() + myView.getRight()) / 2;
    int cy = (myView.getTop() + myView.getBottom()) / 2;

    // get the final radius for the clipping circle
    int finalRadius = Math.max(myView.getWidth(), myView.getHeight());
    AnimatorSet animatorSet = new AnimatorSet();
    // create the animator for this view (the start radius is zero)
    Animator anim =
            ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, finalRadius);
    anim.setDuration(1000);
    anim.setInterpolator(new AccelerateInterpolator());

    Animator anim1 = ObjectAnimator.ofFloat(myView, "translationZ", 0f, 50f);
    anim1.setDuration(1500);
    anim1.setInterpolator(new AccelerateInterpolator());

    animatorSet.play(anim).with(anim1);
    // make the view visible and start the animation
    myView.setVisibility(View.VISIBLE);
    animatorSet.start();
}
 
Example 4
Project: KUtils   File: DividerGridItemDecoration.java   View Source Code Vote up 7 votes
/**
 * 画横向列表的分割线
 */
public void drawHorizontal(Canvas c, RecyclerView parent) {
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);

        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivideHeight;
        final int top = child.getTop() - params.topMargin;
        final int bottom = child.getBottom() + params.bottomMargin;

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 5
Project: YViewPagerDemo   File: YViewPager.java   View Source Code Vote up 7 votes
/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx     Delta scrolled in pixels
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScrollHorizontal(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom()
                    && canScrollHorizontal(child, true, dx, x + scrollX - child.getLeft(),
                    y + scrollY - child.getTop())) {
                return true;
            }
        }
    }
    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}
 
Example 6
Project: HeadlineNews   File: UIDivider.java   View Source Code Vote up 7 votes
/**
 * 绘制横向水平分割线
 */
private void drawHorizontal(Canvas canvas, RecyclerView parent) {
    int top = parent.getPaddingTop();
    int bottom = parent.getMeasuredHeight() - parent.getPaddingBottom();
    int childSize = parent.getChildCount();
    for (int i = 0; i < childSize; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        int left = child.getRight() + layoutParams.rightMargin;
        int right = left + mDividerWidth;

        if (mDividerDrawable != null) {
            //如果是图片分割线,绘制图片
            mDividerDrawable.setBounds(left, top, right, bottom);
            canvas.drawPaint(mPaint);
            mDividerDrawable.draw(canvas);
        } else {
            //绘制矩形
            canvas.drawRect(left, top, right, bottom, mPaint);
        }
    }
}
 
Example 7
Project: NeiHanDuanZiTV   File: CommonTabLayout.java   View Source Code Vote up 7 votes
private void calcOffset() {
        final View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab);
        mCurrentP.left = currentTabView.getLeft();
        mCurrentP.right = currentTabView.getRight();

        final View lastTabView = mTabsContainer.getChildAt(this.mLastTab);
        mLastP.left = lastTabView.getLeft();
        mLastP.right = lastTabView.getRight();

//        Log.d("AAA", "mLastP--->" + mLastP.left + "&" + mLastP.right);
//        Log.d("AAA", "mCurrentP--->" + mCurrentP.left + "&" + mCurrentP.right);
        if (mLastP.left == mCurrentP.left && mLastP.right == mCurrentP.right) {
            invalidate();
        } else {
            mValueAnimator.setObjectValues(mLastP, mCurrentP);
            if (mIndicatorBounceEnable) {
                mValueAnimator.setInterpolator(mInterpolator);
            }

            if (mIndicatorAnimDuration < 0) {
                mIndicatorAnimDuration = mIndicatorBounceEnable ? 500 : 250;
            }
            mValueAnimator.setDuration(mIndicatorAnimDuration);
            mValueAnimator.start();
        }
    }
 
Example 8
Project: GitHub   File: DividerGridItemDecoration.java   View Source Code Vote up 7 votes
public void drawHorizontal(Canvas c, RecyclerView parent) {
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        // 有脚部时,最后一条不画
        if (hasFooter &&
                parent.getChildLayoutPosition(child) == parent.getLayoutManager().getItemCount() - 1) {
            continue;
        }
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getLeft() - params.leftMargin;
        final int right = child.getRight() + params.rightMargin
                + mDivider.getIntrinsicWidth();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 9
Project: GitHub   File: SupportGridItemDecoration.java   View Source Code Vote up 7 votes
public void drawVertical(Canvas c, RecyclerView parent) {
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);

        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int top = child.getTop() - params.topMargin;
        final int bottom = child.getBottom() + params.bottomMargin;
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicWidth();

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 10
Project: GitHub   File: CommonNavigator.java   View Source Code Vote up 6 votes
/**
 * 获取title的位置信息,为打造不同的指示器、各种效果提供可能
 */
private void preparePositionData() {
    mPositionDataList.clear();
    for (int i = 0, j = mNavigatorHelper.getTotalCount(); i < j; i++) {
        PositionData data = new PositionData();
        View v = mTitleContainer.getChildAt(i);
        if (v != null) {
            data.mLeft = v.getLeft();
            data.mTop = v.getTop();
            data.mRight = v.getRight();
            data.mBottom = v.getBottom();
            if (v instanceof IMeasurablePagerTitleView) {
                IMeasurablePagerTitleView view = (IMeasurablePagerTitleView) v;
                data.mContentLeft = view.getContentLeft();
                data.mContentTop = view.getContentTop();
                data.mContentRight = view.getContentRight();
                data.mContentBottom = view.getContentBottom();
            } else {
                data.mContentLeft = data.mLeft;
                data.mContentTop = data.mTop;
                data.mContentRight = data.mRight;
                data.mContentBottom = data.mBottom;
            }
        }
        mPositionDataList.add(data);
    }
}
 
Example 11
Project: SelectName   File: ViewDragHelper.java   View Source Code Vote up 6 votes
/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for
 *               scrollability (true), or just its children (false).
 * @param dx     Delta scrolled in pixels along the X axis
 * @param dy     Delta scrolled in pixels along the Y axis
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft()
                    && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop()
                    && y + scrollY < child.getBottom()
                    && canScroll(child, true, dx, dy, x + scrollX - child.getLeft(), y
                    + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV
            && (ViewCompat.canScrollHorizontally(v, -dx) || ViewCompat.canScrollVertically(v,
            -dy));
}
 
Example 12
Project: redpacketui-open   File: HeaderPositionCalculator.java   View Source Code Vote up 6 votes
/**
 * Determines if an item is obscured by a header
 *
 * @param parent      it is RecyclerView
 * @param item        to determine if obscured by header
 * @param header      that might be obscuring the item
 * @param orientation of the {@link RecyclerView}
 * @return true if the item view is obscured by the header view
 */
private boolean itemIsObscuredByHeader(RecyclerView parent, View item, View header, int orientation) {
    RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) item.getLayoutParams();
    mDimensionCalculator.initMargins(mTempRect1, header);

    int adapterPosition = parent.getChildAdapterPosition(item);
    if (adapterPosition == RecyclerView.NO_POSITION || mHeaderProvider.getHeader(parent, adapterPosition) != header) {
        // Resolves https://github.com/timehop/sticky-headers-recyclerview/issues/36
        // Handles an edge case where a trailing header is smaller than the current sticky header.
        return false;
    }

    if (orientation == LinearLayoutManager.VERTICAL) {
        int itemTop = item.getTop() - layoutParams.topMargin;
        int headerBottom = header.getBottom() + mTempRect1.bottom + mTempRect1.top;
        if (itemTop > headerBottom) {
            return false;
        }
    } else {
        int itemLeft = item.getLeft() - layoutParams.leftMargin;
        int headerRight = header.getRight() + mTempRect1.right + mTempRect1.left;
        if (itemLeft > headerRight) {
            return false;
        }
    }

    return true;
}
 
Example 13
Project: MaterialDesignDemo   File: MyDecorationTwo.java   View Source Code Vote up 6 votes
private void drawHorizontal(Canvas c, RecyclerView parent) {
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int left = child.getLeft() - params.leftMargin;
        int top = child.getBottom() + params.bottomMargin;
        int right = child.getRight() + params.rightMargin;
        int bottom = top + mDivider.getMinimumHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 14
Project: OpenLibre   File: DividerItemDecoration.java   View Source Code Vote up 6 votes
private void drawHorizontal(Canvas c, RecyclerView parent) {
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
                .getLayoutParams();
        final int left = child.getRight() + params.rightMargin;
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
 
Example 15
Project: GitHub   File: Utils.java   View Source Code Vote up 6 votes
static int getStart(View v, boolean withoutPadding) {
  if (v == null) {
    return 0;
  }
  if (isLayoutRtl(v)) {
    return (withoutPadding) ? v.getRight() - getPaddingStart(v) : v.getRight();
  } else {
    return (withoutPadding) ? v.getLeft() + getPaddingStart(v) : v.getLeft();
  }
}
 
Example 16
Project: letv   File: HListView.java   View Source Code Vote up 5 votes
private View moveSelection(View oldSel, View newSel, int delta, int childrenLeft, int childrenRight) {
    View sel;
    int fadingEdgeLength = getHorizontalFadingEdgeLength();
    int selectedPosition = this.mSelectedPosition;
    int leftSelectionPixel = getLeftSelectionPixel(childrenLeft, fadingEdgeLength, selectedPosition);
    int rightSelectionPixel = getRightSelectionPixel(childrenLeft, fadingEdgeLength, selectedPosition);
    int halfHorizontalSpace;
    if (delta > 0) {
        oldSel = makeAndAddView(selectedPosition - 1, oldSel.getLeft(), true, this.mListPadding.top, false);
        int dividerWidth = this.mDividerWidth;
        sel = makeAndAddView(selectedPosition, oldSel.getRight() + dividerWidth, true, this.mListPadding.top, true);
        if (sel.getRight() > rightSelectionPixel) {
            halfHorizontalSpace = (childrenRight - childrenLeft) / 2;
            int offset = Math.min(Math.min(sel.getLeft() - leftSelectionPixel, sel.getRight() - rightSelectionPixel), halfHorizontalSpace);
            oldSel.offsetLeftAndRight(-offset);
            sel.offsetLeftAndRight(-offset);
        }
        if (this.mStackFromRight) {
            fillRight(this.mSelectedPosition + 1, sel.getRight() + dividerWidth);
            adjustViewsLeftOrRight();
            fillLeft(this.mSelectedPosition - 2, sel.getLeft() - dividerWidth);
        } else {
            fillLeft(this.mSelectedPosition - 2, sel.getLeft() - dividerWidth);
            adjustViewsLeftOrRight();
            fillRight(this.mSelectedPosition + 1, sel.getRight() + dividerWidth);
        }
    } else if (delta < 0) {
        if (newSel != null) {
            sel = makeAndAddView(selectedPosition, newSel.getLeft(), true, this.mListPadding.top, true);
        } else {
            sel = makeAndAddView(selectedPosition, oldSel.getLeft(), false, this.mListPadding.top, true);
        }
        if (sel.getLeft() < leftSelectionPixel) {
            halfHorizontalSpace = (childrenRight - childrenLeft) / 2;
            View view = sel;
            view.offsetLeftAndRight(Math.min(Math.min(leftSelectionPixel - sel.getLeft(), rightSelectionPixel - sel.getRight()), halfHorizontalSpace));
        }
        fillBeforeAndAfter(sel, selectedPosition);
    } else {
        int oldLeft = oldSel.getLeft();
        sel = makeAndAddView(selectedPosition, oldLeft, true, this.mListPadding.top, true);
        if (oldLeft < childrenLeft && sel.getRight() < childrenLeft + 20) {
            sel.offsetLeftAndRight(childrenLeft - sel.getLeft());
        }
        fillBeforeAndAfter(sel, selectedPosition);
    }
    return sel;
}
 
Example 17
Project: decoy   File: PagerSlidingTabStrip.java   View Source Code Vote up 5 votes
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;
    }

    final int height = getHeight();

    // draw underline
    rectPaint.setColor(underlineColor);
    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw indicator line
    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }

    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}
 
Example 18
Project: AndroidBackendlessChat   File: PagerSlidingTabStrip.java   View Source Code Vote up 5 votes
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);

	if (isInEditMode() || tabCount == 0) {
		return;
	}

	final int height = getHeight();

	// draw indicator line

	rectPaint.setColor(indicatorColor);

	// default: line below current tab
	View currentTab = tabsContainer.getChildAt(currentPosition);
	float lineLeft = currentTab.getLeft();
	float lineRight = currentTab.getRight();

	// if there is an offset, start interpolating left and right coordinates between current and next tab
	if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

		View nextTab = tabsContainer.getChildAt(currentPosition + 1);
		final float nextTabLeft = nextTab.getLeft();
		final float nextTabRight = nextTab.getRight();

		lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
		lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
	}

	canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

	// draw underline

	rectPaint.setColor(underlineColor);
	canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

	// draw divider

	dividerPaint.setColor(dividerColor);
	for (int i = 0; i < tabCount - 1; i++) {
		View tab = tabsContainer.getChildAt(i);
		canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
	}
}
 
Example 19
Project: Hotspot-master-devp   File: PagerSlidingTabStrip.java   View Source Code Vote up 5 votes
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isInEditMode() || tabCount == 0) {
        return;
    }
    final int height = getHeight();

    // draw underline
    rectPaint.setColor(underlineColor);
    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw indicator line
    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }

    if (indicatorWrap){
        canvas.drawRect(lineLeft+tabPadding, height - indicatorHeight, lineRight-tabPadding, height, rectPaint);
    }else{
        canvas.drawRect(lineLeft+tabPadding, height - indicatorHeight, lineRight-tabPadding, height, rectPaint);
    }


    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPaddingTopBottom, tab.getRight(), height - dividerPaddingTopBottom, dividerPaint);
    }
}
 
Example 20
Project: SelectName   File: ViewDragHelper.java   View Source Code Vote up 4 votes
/**
 * Determine if the supplied view is under the given point in the parent
 * view's coordinate system.
 *
 * @param view Child view of the parent to hit test
 * @param x    X position to test in the parent's coordinate system
 * @param y    Y position to test in the parent's coordinate system
 * @return true if the supplied view is under the given point, false
 * otherwise
 */
public boolean isViewUnder(View view, int x, int y) {
    if (view == null) {
        return false;
    }
    return x >= view.getLeft() && x < view.getRight() && y >= view.getTop()
            && y < view.getBottom();
}