Example usage for android.view View getRight

List of usage examples for android.view View getRight

Introduction

In this page you can find the example usage for android.view View getRight.

Prototype

@ViewDebug.CapturedViewProperty
public final int getRight() 

Source Link

Document

Right position of this view relative to its parent.

Usage

From source file:Main.java

public static float getViewX(View view) {
    return Math.abs((view.getRight() - view.getLeft()) / 2);
}

From source file:Main.java

static public Rect getFrame(View v) {
    return new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
}

From source file:Main.java

public static boolean pointInView(View view, float localX, float localY) {
    return localX >= 0 && localX < (view.getRight() - view.getLeft()) && localY >= 0
            && localY < (view.getBottom() - view.getTop());
}

From source file:Main.java

static public Rect getPaddedFrame(View v) {
    return new Rect(v.getLeft() + v.getPaddingLeft(), v.getTop() + v.getPaddingTop(),
            v.getRight() - v.getPaddingRight(), v.getBottom() - v.getPaddingBottom());
}

From source file:Main.java

public static void invalidateGlobalRegion(View view) {
    invalidateGlobalRegion(view, new RectF(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
}

From source file:Main.java

public static boolean isMotionOnView(View view, MotionEvent event) {
    final float x = event.getX();
    final float y = event.getY();
    if (x < view.getRight() && x > view.getLeft() && y < view.getBottom() && y > view.getTop()) {
        return true;
    }/*from   w  w  w .  j  av  a2  s . c  o  m*/
    return false;
}

From source file:Main.java

/**
 * Utility method to determine whether the given point, in local coordinates,
 * is inside the view, where the area of the view is expanded by the slop factor.
 * This method is called while processing touch-move events to determine if the event
 * is still within the view./*from  ww w.j a va 2s  .  com*/
 */
private static boolean pointInView(View v, float localX, float localY, float slop) {
    return localX >= -slop && localY >= -slop && localX < ((v.getRight() - v.getLeft()) + slop)
            && localY < ((v.getBottom() - v.getTop()) + slop);
}

From source file:Main.java

public static boolean pointInView(@NonNull View view, float localX, float localY, float slop) {
    return localX >= view.getLeft() - slop && localX < view.getRight() + slop && localY >= view.getTop() - slop
            && localY < view.getBottom() + slop;
}

From source file:Main.java

/**
 * Helper for overriding {@link ViewGroup#gatherTransparentRegion} for views that are fully
 * opaque and have children extending beyond their bounds. If the transparent region
 * optimization is turned on (which is the case whenever the view hierarchy contains a
 * SurfaceView somewhere), the children might otherwise confuse the SurfaceFlinger.
 */// w  w w  . j a v  a2s . c o  m
public static void gatherTransparentRegionsForOpaqueView(View view, Region region) {
    view.getLocationInWindow(sLocationTmp);
    region.op(sLocationTmp[0], sLocationTmp[1], sLocationTmp[0] + view.getRight() - view.getLeft(),
            sLocationTmp[1] + view.getBottom() - view.getTop(), Region.Op.DIFFERENCE);
}

From source file:Main.java

public static void drawTopAlignItem(Canvas canvas, Drawable drawable, View child,
        ViewGroup.MarginLayoutParams params) {

    final int left = child.getLeft() - params.leftMargin;
    final int right = child.getRight() + params.rightMargin;
    final int top = child.getTop() - params.topMargin - drawable.getIntrinsicHeight();
    final int bottom = top + drawable.getIntrinsicHeight();

    drawable.setBounds(left, top, right, bottom);
    drawable.draw(canvas);//  ww  w  .  j a  v  a2s.  com
}