Example usage for android.view View setPivotX

List of usage examples for android.view View setPivotX

Introduction

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

Prototype

public void setPivotX(float pivotX) 

Source Link

Document

Sets the x location of the point around which the view is #setRotation(float) rotated and #setScaleX(float) scaled .

Usage

From source file:Main.java

/**
 * Animator to animate X scale of the view. Y scale is constant
 *
 * @param view View to be animated//from  w ww  .ja v  a2  s  . c  o m
 * @param pivotX x coordinate of the pivot
 * @param pivotY y coordinate of the pivot
 * @param fromScale initial scale
 * @param toScale final scale
 * @param duration animation duration in milliseconds
 * @return Animator Object
 */
@NonNull
public static Animator scaleX(@NonNull View view, int pivotX, int pivotY, float fromScale, float toScale,
        int duration) {
    view.setPivotX(pivotX);
    view.setPivotY(pivotY);
    Animator animator = ObjectAnimator.ofFloat(view, "scaleX", fromScale, toScale);
    animator.setDuration(duration);
    return animator;
}

From source file:Main.java

/**
 * Animator to animate Y scale of the view. X scale is constant
 *
 * @param view View to be animated//from   www . j a  v a2 s .  c o m
 * @param pivotX x coordinate of the pivot
 * @param pivotY y coordinate of the pivot
 * @param fromScale initial scale
 * @param toScale final scale
 * @param duration animation duration in milliseconds
 * @return Animator Object
 */
@NonNull
public static Animator scaleY(@NonNull View view, int pivotX, int pivotY, float fromScale, float toScale,
        int duration) {
    view.setPivotX(pivotX);
    view.setPivotY(pivotY);
    Animator animator = ObjectAnimator.ofFloat(view, "scaleY", fromScale, toScale);
    animator.setDuration(duration);
    return animator;
}

From source file:com.kogitune.activitytransition.core.TransitionAnimation.java

private static void runEnterAnimation(MoveData moveData, TimeInterpolator interpolator) {
    final View toView = moveData.toView;
    toView.setPivotX(0);
    toView.setPivotY(0);/*from  www .ja v  a2s.  c  o  m*/
    toView.setScaleX(moveData.widthScale);
    toView.setScaleY(moveData.heightScale);
    toView.setTranslationX(moveData.leftDelta);
    toView.setTranslationY(moveData.topDelta);

    toView.animate().setDuration(moveData.duration).scaleX(1).scaleY(1).translationX(0).translationY(0)
            .setInterpolator(interpolator);
}

From source file:com.dgsd.android.ShiftTracker.Util.PageTransformerUtils.java

public static ViewPager.PageTransformer getTwistTransformer() {
    if (mTwistTransformer == null) {
        mTwistTransformer = new ViewPager.PageTransformer() {
            @Override/*from  ww  w.jav  a 2s.c  o  m*/
            public void transformPage(View view, float position) {
                if (!Api.isMin(Api.HONEYCOMB))
                    return;

                view.setPivotX(0);
                view.setPivotY(0);

                final float distFromZero = Math.abs(position);
                view.animate().alpha(1.0f - distFromZero).rotation(90 * position).setDuration(0).start();
            }
        };
    }

    return mTwistTransformer;
}

From source file:com.fastbootmobile.encore.utils.Utils.java

public static void animateScale(View v, boolean animate, boolean visible) {
    v.setPivotX(v.getMeasuredWidth() / 2);
    v.setPivotY(v.getMeasuredHeight() / 2);

    if (visible) {
        if (animate) {
            v.animate().scaleX(1.0f).scaleY(1.0f).alpha(1.0f).translationY(0.0f).setDuration(400)
                    .setInterpolator(new DecelerateInterpolator()).start();
        } else {//from  ww w  . java 2 s .  com
            v.setScaleX(1.0f);
            v.setScaleY(1.0f);
            v.setAlpha(1.0f);
            v.setTranslationY(0.0f);
        }
    } else {
        if (animate) {
            v.animate().scaleX(0.0f).scaleY(0.0f).alpha(0.0f).translationY(v.getHeight() / 4).setDuration(400)
                    .setInterpolator(new DecelerateInterpolator()).start();
        } else {
            v.setScaleX(0.0f);
            v.setScaleY(0.0f);
            v.setAlpha(0.0f);
            v.setTranslationY(v.getHeight() / 4);
        }
    }
}

From source file:com.suyonoion.floatingchathead.CubeOutTransformer.java

@Override
public void transformPage(View page, float position) {
    page.setPivotX(position < 0f ? page.getWidth() : 0f);
    page.setPivotY(page.getHeight() * 0.5f);
    page.setRotationY(90f * position);/*from  ww  w.  j a va  2s.c  o  m*/
}

From source file:com.suyonoion.easystlviewpagerui.CubeOutTransformer.java

public void transformPage(View view, float position) {
    final float rotation = (position < 0 ? 90f : -90f) * Math.abs(position);
    view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
    view.setPivotX(position < 0f ? view.getWidth() : 0f);
    view.setPivotY(view.getHeight() * 0.5f);
    view.setRotationY(90f * position);//from w ww  .  j  av  a2  s  .  c  o m
}

From source file:com.suyonoion.easyviewpagerui.CubeOutTransformer.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void transformPage(View view, float position) {
    final float rotation = (position < 0 ? 90f : -90f) * Math.abs(position);
    view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
    view.setPivotX(position < 0f ? view.getWidth() : 0f);
    view.setPivotY(view.getHeight() * 0.5f);
    view.setRotationY(90f * position);/*  ww  w .  j av a  2s .c  om*/
}

From source file:de.base.utility.animators.ScaleInAnimator.java

public void scaleSingleView(View view, float toScale, int pivotX, int pivotY, @Nullable Runnable startAction,
        @Nullable Runnable endAction) {
    view.setPivotX(pivotX);
    view.setPivotY(pivotY);/*from  w  w w  .j a va 2  s.  c om*/
    animateAdd(view, toScale, startAction, endAction, null);
}

From source file:com.aran.bang.widget.BaseTransformer.java

/**
 * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called.
 *
 * @param view/* w ww . ja  v a 2  s .c  o  m*/
 * @param position
 */
protected void onPreTransform(View view, float position) {
    final float width = view.getWidth();

    view.setRotationX(0);
    view.setRotationY(0);
    view.setRotation(0);
    view.setScaleX(1);
    view.setScaleY(1);
    view.setPivotX(0);
    view.setPivotY(0);
    view.setTranslationY(0);
    view.setTranslationX(isPagingEnabled() ? 0f : -width * position);

    if (hideOffscreenPages()) {
        view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f);
    } else {
        view.setAlpha(1f);
    }
}