Example usage for android.view View getLeft

List of usage examples for android.view View getLeft

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final int getLeft() 

Source Link

Document

Left position of this view relative to its parent.

Usage

From source file:Main.java

public static void drawBottomAlignItem(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.getBottom() + params.bottomMargin;
    final int bottom = top + drawable.getIntrinsicHeight();

    drawable.setBounds(left, top, right, bottom);
    drawable.draw(canvas);/*from w ww .j  a  v  a2  s  .  co m*/
}

From source file:Main.java

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

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

    drawable.setBounds(left, top, right, bottom);
    drawable.draw(canvas);/*from ww  w.ja  va2 s.  c  om*/
}

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

/**
 * 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 w  w w  .  j  av  a2 s  .c  o m*/
 */
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 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 a v  a2s  .  c  om
    return false;
}

From source file:Main.java

public static int getRelativeLeft(View myView) {
    //       if (myView.getParent() == myView.getRootView())
    if (myView.getId() == android.R.id.content) {
        return myView.getLeft();
    } else {/*from   ww  w  .jav a 2 s. c o m*/
        return myView.getLeft() + getRelativeLeft((View) myView.getParent());
    }
}

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.
 *//*ww  w  . j  a  va2 s.  com*/
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

static int getEnd(View v, boolean withoutPadding) {
    if (v == null) {
        return 0;
    }//from w  w w . ja  v a  2 s  .c  o  m
    if (isLayoutRtl(v)) {
        return (withoutPadding) ? v.getLeft() + getPaddingEnd(v) : v.getLeft();
    } else {
        return (withoutPadding) ? v.getRight() - getPaddingEnd(v) : v.getRight();
    }
}

From source file:Main.java

public static Bitmap getBitmapFromView(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
    view.draw(canvas);// w w  w.j  a v  a 2  s. c o  m

    return bitmap;
}

From source file:Main.java

public static BitmapDrawable createDrawableFromView(Context context, View v) {
    Bitmap b = Bitmap.createBitmap(v.getLayoutParams().width, v.getLayoutParams().height,
            Bitmap.Config.ARGB_8888);/*from ww  w.  j  ava 2  s  .  c om*/
    Canvas c = new Canvas(b);
    v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    v.draw(c);
    return new BitmapDrawable(context.getResources(), b);
}