Example usage for android.view View getX

List of usage examples for android.view View getX

Introduction

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

Prototype

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

Source Link

Document

The visual x position of this view, in pixels.

Usage

From source file:Main.java

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

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

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   w  w w . j  ava2  s  . c om
    scaleInAnimation.setFillAfter(false);
    v.startAnimation(scaleInAnimation);
}

From source file:Main.java

/**
 * Animates a view sliding in from the left
 * @param view/*from   w w w  . ja  v  a 2  s.  c  o m*/
 */
public static void slideInLeft(final View view, int duration) {
    final Animation inLeft = new TranslateAnimation(view.getX() - view.getWidth(), 0, 0, view.getX());
    inLeft.setDuration(duration);
    view.startAnimation(inLeft);
}

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   w ww  .j  a  v a  2 s.c  o  m
    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: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:com.freshdigitable.udonroad.ffab.ActionIndicatorView.java

private static float calcCenterX(View ic) {
    return ic.getX() + ic.getWidth() / 2;
}

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   ww w. j  ava  2s  . c  om
 * @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 x coordinates of a view by tracing up its hierarchy.
 *//*w ww . jav a 2  s.c o  m*/
private static int getX(View view) {
    int x = 0;
    while (view != null) {
        x += (int) view.getX();
        view = (View) view.getParent();
    }
    return x;
}

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);//from   w w  w. j  a  v a  2  s  .c o  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) {
        }
    });
}