Example usage for android.view View getY

List of usage examples for android.view View getY

Introduction

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

Prototype

@ViewDebug.ExportedProperty(category = "drawing")
public float getY() 

Source Link

Document

The visual y position of this view, in pixels.

Usage

From source file:Main.java

public static float getY(View view) {
    return view.getY();
}

From source file:Main.java

/**
 * @param view//from w w w.  jav  a  2 s  .  c o  m
 * @return
 */
public static boolean isReset(View view) {
    return view.getTop() == view.getY();
}

From source file:Main.java

public static void updateAnimation(final View v) {
    final ScaleAnimation scaleInAnimation = new ScaleAnimation(v.getX(), v.getX() + 1, v.getY(), v.getY() + 1,
            v.getPivotX(), v.getPivotY());
    scaleInAnimation.setDuration(200);//from   ww w  .java2 s .com
    scaleInAnimation.setFillAfter(false);
    v.startAnimation(scaleInAnimation);
}

From source file:Main.java

public static Point getCenter(View v) {
    Point point = new Point();
    point.x = (int) (v.getX() + (v.getMeasuredWidth() / 2));
    point.y = (int) (v.getY() + (v.getMeasuredHeight() / 2));
    return point;
}

From source file:Main.java

private static int[] calulateCorner(View view, int cornerType) {
    int x = (int) view.getX();
    int y = (int) view.getY();
    int w = view.getWidth();
    int h = view.getHeight();
    int[] amaya = new int[3];
    switch (cornerType) {
    default://from   www. j  a va  2  s .  c  om
    case START_LEFT_TOP:
        amaya[0] = x;
        amaya[1] = y;
        break;
    case START_LEFT_BOTTOM:
        amaya[0] = x;
        amaya[1] = y + h;
        break;
    case START_RIGHT_TOP:
        amaya[0] = x + w;
        amaya[1] = y;
        break;
    case START_RIGHT_BOTTOM:
        amaya[0] = x + w;
        amaya[1] = y + h;
        break;
    case START_CENTER:
        amaya[0] = x + w / 2;
        amaya[1] = y + h / 2;
        break;
    }
    amaya[2] = (int) Math.sqrt(w * w + h * h);
    return amaya;
}

From source file:com.freshdigitable.udonroad.ffab.ActionIndicatorView.java

private static float calcCenterY(View ic) {
    return ic.getY() + ic.getHeight() / 2;
}

From source file:Main.java

public static Bitmap crop(Bitmap srcBmp, View canvasView, int downsampling) {
    float scale = 1f / downsampling;
    return Bitmap.createBitmap(srcBmp, (int) Math.floor((canvasView.getX()) * scale),
            (int) Math.floor((canvasView.getY()) * scale), (int) Math.floor((canvasView.getWidth()) * scale),
            (int) Math.floor((canvasView.getHeight()) * scale));
}

From source file:Main.java

/**
 * Return the position of {@code childView} relative to {@code rootView}.  {@code childView}
 * must be a child of {@code rootView}.  This returns the relative draw position, which includes
 * translations./*from w  ww  .  j a v  a 2 s .c o m*/
 * @param rootView    The parent of {@code childView} to calculate the position relative to.
 * @param childView   The {@link View} to calculate the position of.
 * @param outPosition The resulting position with the format [x, y].
 */
public static void getRelativeDrawPosition(View rootView, View childView, int[] outPosition) {
    assert outPosition.length == 2;
    outPosition[0] = 0;
    outPosition[1] = 0;
    while (childView != null && childView != rootView) {
        outPosition[0] += childView.getX();
        outPosition[1] += childView.getY();
        childView = (View) childView.getParent();
    }
}

From source file:com.android.mail.browse.ConversationItemViewCoordinates.java

/**
 * Returns the y coordinates of a view by tracing up its hierarchy.
 *//*from   w  w  w.j  a  va2s.c  om*/
private static int getY(View view) {
    int y = 0;
    while (view != null) {
        y += (int) view.getY();
        view = (View) view.getParent();
    }
    return y;
}

From source file:Main.java

public static void linearAnimation(final View view, final int startX, final int startY, final int endX,
        final int endY, long duration, final Runnable callback) {
    Animation anim = new TranslateAnimation(startX, endX, startY, endY);
    anim.setDuration(duration);// ww w.  j  a v a  2s  .  co  m
    anim.setInterpolator(new DecelerateInterpolator());
    view.startAnimation(anim);

    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.clearAnimation();
            view.setX(view.getX() + endX);
            view.setY(view.getY() + endY);

            if (callback != null)
                callback.run();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
}