Java Code Examples for android.animation.PropertyValuesHolder.ofFloat()

The following are Jave code examples for showing how to use ofFloat() of the android.animation.PropertyValuesHolder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AnimationShowcase   File: ObjectAnimatorActivity.java   Source Code and License Vote up 6 votes
@OnClick(R.id.translateAndFadeWithPropertyValuesHolder)
public void onTranslateAndFadeWithPropertyValuesHolder() {
    /*
     * https://android-developers.googleblog.com/2011/05/introducing-viewpropertyanimator.html
     * The code above code creates three separate animations and plays them together in an AnimatorSet.
     * This means that there is the processing overhead of setting up the AnimatorSet
     * and running three Animators in parallel to animate these x/y/alpha properties.
     * There is an alternative approach using PropertyValuesHolder that you can use to combine multiple properties inside of one single Animator:
     */
    PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("translationX", icon.getTranslationX(), animateForward ? icon.getWidth() * 2 : 0.0f);
    PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("translationY", icon.getTranslationY(), animateForward ? icon.getHeight() * 4 : 0.0f);
    PropertyValuesHolder pvhAlpha = PropertyValuesHolder.ofFloat("alpha", icon.getAlpha(), animateForward ? 0.0f : 1.0f);

    Animator animator = ObjectAnimator.ofPropertyValuesHolder(icon, pvhX, pvhY, pvhAlpha);
    animator.setDuration(FULL_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.start();

    animateForward = !animateForward;
}
 
Example 2
Project: LiveGiftLayout   File: CustormAnim.java   Source Code and License Vote up 6 votes
@NonNull
    private AnimatorSet testAnim(GiftFrameLayout giftFrameLayout) {
        PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0, -50);
        PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.5f);
        ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator.setStartDelay(0);
        animator.setDuration(1500);

        translationY = PropertyValuesHolder.ofFloat("translationY", -50, -100);
        alpha = PropertyValuesHolder.ofFloat("alpha", 0.5f, 0f);
        ObjectAnimator animator1 = ObjectAnimator.ofPropertyValuesHolder(giftFrameLayout, translationY, alpha);
        animator1.setStartDelay(0);
        animator1.setDuration(1500);

        // 复原
//        ObjectAnimator fadeAnimator2 = GiftAnimationUtil.createFadeAnimator(giftFrameLayout, 0, 0, 0, 0);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(animator1).after(animator);
//        animatorSet.play(fadeAnimator2).after(animator1);
        animatorSet.start();
        return animatorSet;
    }
 
Example 3
Project: PinchToZoom   File: ImageMatrixTouchHandler.java   Source Code and License Vote up 6 votes
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
	if (mode == DRAG) {
		if (flingDuration > 0 && !isAnimating()) {
			float factor = ((float) flingDuration / 1000f) * flingExaggeration;
			float[] values = corrector.getValues();
			float dx = (velocityX * factor) * values[Matrix.MSCALE_X];
			float dy = (velocityY * factor) * values[Matrix.MSCALE_Y];
			PropertyValuesHolder flingX = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_X, values[Matrix.MTRANS_X], values[Matrix.MTRANS_X] + dx);
			PropertyValuesHolder flingY = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_Y, values[Matrix.MTRANS_Y], values[Matrix.MTRANS_Y] + dy);
			valueAnimator = ValueAnimator.ofPropertyValuesHolder(flingX, flingY);
			valueAnimator.setDuration(flingDuration);
			valueAnimator.addUpdateListener(new FlingAnimatorHandler(corrector));
			valueAnimator.setInterpolator(new DecelerateInterpolator());
			valueAnimator.start();
			return true;
		}
	}
	return super.onFling(e1, e2, velocityX, velocityY);
}
 
Example 4
Project: FloatingNew   File: DefaultAnimationHandler.java   Source Code and License Vote up 5 votes
@Override
public void animateMenuClosing(Point center) {
    super.animateMenuOpening(center);

    setAnimating(true);

    Animator lastAnimation = null;
    for (int i = 0; i < menu.getSubActionItems().size(); i++) {
        PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, - (menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2));
        PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, - (menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2));
        PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, -720);
        PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
        PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
        PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 0);

        final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA);
        animation.setDuration(DURATION);
        animation.setInterpolator(new AccelerateDecelerateInterpolator());
        animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.CLOSING));

        if(i == 0) {
            lastAnimation = animation;
        }

        animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
        animation.start();
    }
    if(lastAnimation != null) {
        lastAnimation.addListener(new LastAnimationListener());
    }
}
 
Example 5
Project: chromium-for-android-56-debug-video   File: StackViewAnimation.java   Source Code and License Vote up 5 votes
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 6
Project: buildAPKsSamples   File: SquashAndStretch.java   Source Code and License Vote up 5 votes
public void onButtonClick(View view) {
    long animationDuration = (long) (BASE_DURATION * sAnimatorScale);

    // Scale around bottom/middle to simplify squash against the window bottom
    view.setPivotX(view.getWidth() / 2);
    view.setPivotY(view.getHeight());
    
    // Animate the button down, accelerating, while also stretching in Y and squashing in X
    PropertyValuesHolder pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y,
            mContainer.getHeight() - view.getHeight());
    PropertyValuesHolder pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, .7f);
    PropertyValuesHolder pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1.2f);
    ObjectAnimator downAnim = ObjectAnimator.ofPropertyValuesHolder(
            view, pvhTY, pvhSX, pvhSY);
    downAnim.setInterpolator(sAccelerator);
    downAnim.setDuration((long) (animationDuration * 2));

    // Stretch in X, squash in Y, then reverse
    pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 2);
    pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, .5f);
    ObjectAnimator stretchAnim =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhSX, pvhSY);
    stretchAnim.setRepeatCount(1);
    stretchAnim.setRepeatMode(ValueAnimator.REVERSE);
    stretchAnim.setInterpolator(sDecelerator);
    stretchAnim.setDuration(animationDuration);
    
    // Animate back to the start
    pvhTY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0);
    pvhSX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
    pvhSY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
    ObjectAnimator upAnim =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhTY, pvhSX, pvhSY);
    upAnim.setDuration((long) (animationDuration * 2));
    upAnim.setInterpolator(sDecelerator);

    AnimatorSet set = new AnimatorSet();
    set.playSequentially(downAnim, stretchAnim, upAnim);
    set.start();
}
 
Example 7
Project: FlickLauncher   File: Workspace.java   Source Code and License Vote up 5 votes
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete,
        final boolean stripEmptyScreens) {
    // XXX: Do we need to update LM workspace screens below?
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
    PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f);

    final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);

    mRemoveEmptyScreenRunnable = new Runnable() {
        @Override
        public void run() {
            if (hasExtraEmptyScreen()) {
                mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
                mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID);
                removeView(cl);
                if (stripEmptyScreens) {
                    stripEmptyScreens();
                }
                // Update the page indicator to reflect the removed page.
                showPageIndicatorAtCurrentScroll();
            }
        }
    };

    ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha);
    oa.setDuration(duration);
    oa.setStartDelay(delay);
    oa.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (mRemoveEmptyScreenRunnable != null) {
                mRemoveEmptyScreenRunnable.run();
            }
            if (onComplete != null) {
                onComplete.run();
            }
        }
    });
    oa.start();
}
 
Example 8
Project: morphos   File: TranslationAnimation.java   Source Code and License Vote up 5 votes
@Override
public Animator buildAnimation(@NonNull ViewDefault viewDefault, @NonNull View viewToMorph, boolean isReversed) {
    float moveToX = 0, moveToY = 0, moveToZ = 0;
    if (target == AnimationTarget.TO) {
        if (!isReversed) {
            initialValueX = viewDefault.getX();
            initialValueY = viewDefault.getY();
            initialValueZ = viewDefault.getZ();
        }
        moveToX = isReversed ? initialValueX : translationValueX;
        moveToY = isReversed ? initialValueY : translationValueY;
        moveToZ = isReversed ? initialValueZ : translationValueZ;
        viewDefault.setX(moveToX);
        viewDefault.setY(moveToY);
        viewDefault.setZ(moveToZ);
    } else if (target == AnimationTarget.BY) {
        moveToX = viewDefault.getX() + (isReversed ? -translationValueX : translationValueX);
        moveToY = viewDefault.getY() + (isReversed ? -translationValueY : translationValueY);
        moveToZ = viewDefault.getZ() + (isReversed ? -translationValueZ : translationValueZ);
        viewDefault.setX(moveToX);
        viewDefault.setY(moveToY);
        viewDefault.setZ(moveToZ);
    }
    PropertyValuesHolder[] parameters = new PropertyValuesHolder[atLeastLollipop ? 3 : 2];
    parameters[0] = PropertyValuesHolder.ofFloat(View.X, moveToX);
    parameters[1] = PropertyValuesHolder.ofFloat(View.Y, moveToY);
    if (atLeastLollipop) {
        parameters[2] = PropertyValuesHolder.ofFloat(View.Z, moveToZ);
    }
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(viewToMorph, parameters);
    if (duration >= 0) {
        animator.setDuration(duration);
    }
    if (interpolator != null) {
        animator.setInterpolator(interpolator);
    }
    return animator;
}
 
Example 9
Project: SwipeBackController   File: SwipeBackController.java   Source Code and License Vote up 5 votes
private void createBackAnimator(
        float xStart,
        float xEnd,
        float distanceXStart,
        float distanceXEnd,
        float fractionXStart,
        float fractionXEnd) {
    mBackAnimator = new ValueAnimator();
    mXHolder = PropertyValuesHolder.ofFloat(mXHolderName, xStart, xEnd);
    mDistanceXHolder = PropertyValuesHolder.ofFloat(mDistanceXHolderName, distanceXStart, distanceXEnd);
    mFractionXHolder = PropertyValuesHolder.ofFloat(mFractionXHolderName, fractionXStart, fractionXEnd);

    mBackAnimator = ValueAnimator.ofPropertyValuesHolder(
            mXHolder,
            //        mYHolder,
            mDistanceXHolder,
            //        mDistanceYHolder
            mFractionXHolder
            //        mFractionYHolder
    );
    mBackAnimator.setDuration(mAnimationBackDuration);
    mBackAnimator.setInterpolator(mBackAnimInterpolator);
    mBackAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float x = (float) valueAnimator.getAnimatedValue(mXHolderName);
            float distanceX = (float) valueAnimator.getAnimatedValue(mDistanceXHolderName);
            float fractionX = (float) valueAnimator.getAnimatedValue(mFractionXHolderName);

            handleListeners(x, distanceX, fractionX);
        }
    });
}
 
Example 10
Project: Android-CoolMenu   File: CoolMenu.java   Source Code and License Vote up 5 votes
public void show() {

        int childCount = getChildCount();
        if (childCount > 1) {

            mAngle = 0;//复位

            float x = 0.5f * mEdge;
            float y = 0.5f * mEdge;
            Animator[] anim = new Animator[childCount];

            for (int i = 0; i < childCount; i++) {

                View child = getChildAt(i);
                float pivotX = x - child.getLeft();
                float pivotY = y - child.getTop();
                child.setPivotX(pivotX);
                child.setPivotY(pivotY);
                float childX = 0.5f * child.getLeft() + child.getRight() * 0.5f;
                float childY = 0.5f * child.getTop() + 0.5f * child.getBottom();

                PropertyValuesHolder ca = PropertyValuesHolder.ofFloat("alpha", 0.5f, 1.0f);
                PropertyValuesHolder csx = PropertyValuesHolder.ofFloat("scaleX", 0, 1.0f);
                PropertyValuesHolder csy = PropertyValuesHolder.ofFloat("scaleY", 0, 1.0f);

                if (i == 0) {

                    anim[i] = ObjectAnimator.ofPropertyValuesHolder(child, ca, csx, csy);
                } else {
                    PropertyValuesHolder ctx = PropertyValuesHolder.ofFloat("translationX", -x + childX, 0);
                    PropertyValuesHolder cty = PropertyValuesHolder.ofFloat("translationY", -y + childY, 0);
                    PropertyValuesHolder cr = PropertyValuesHolder.ofFloat("rotation", 0, 360f);
                    anim[i] = ObjectAnimator.ofPropertyValuesHolder(child, ctx, cty, ca, csx, csy, cr);
                }
            }

            AnimatorSet set = new AnimatorSet();
            set.setDuration(ANIM_SHOW_DURATION);
            set.setInterpolator(new LinearInterpolator());
            set.playTogether(anim);
            set.start();
        }
    }
 
Example 11
Project: DailyStudy   File: AnimationDemoActivity.java   Source Code and License Vote up 5 votes
/**
 *
 */
private void propertyValuesHolder() {
    PropertyValuesHolder holder = PropertyValuesHolder.ofFloat("translationX", 0, 300);
    PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f, 1f);
    PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f, 1f);
    ObjectAnimator.ofPropertyValuesHolder(content, holder, holder1, holder2).setDuration(1000).start();
}
 
Example 12
Project: Flubber   File: Flash.java   Source Code and License Vote up 5 votes
@Override
public Animator getAnimationFor(AnimationBody animationBody, View view) {
    final PropertyValuesHolder alphaPVH = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f);
    final ValueAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, alphaPVH);

    return animation;
}
 
Example 13
Project: mao-android   File: CaptureButton.java   Source Code and License Vote up 5 votes
private void init() {
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.4f, 1.0f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f, 1.5f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f, 1.5f);
    mScaleUpAnimator = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY).setDuration(200);
    mScaleUpAnimator.setStartDelay(100);
    mScaleUpAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0.4f, 1.0f);
    scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.5f, 1.0f);
    scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.5f, 1.0f);
    mScaleDownAnimator = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY).setDuration(200);
    mScaleDownAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
}
 
Example 14
Project: Flubber   File: ZoomIn.java   Source Code and License Vote up 5 votes
@Override
public Animator getAnimationFor(AnimationBody animationBody, View view) {

    final float scale = 2 * animationBody.getForce();

    final PropertyValuesHolder alphaPVH = PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 1f);
    final PropertyValuesHolder scaleXPVH = PropertyValuesHolder.ofFloat(View.SCALE_X, scale, 1f);
    final PropertyValuesHolder scaleYPVH = PropertyValuesHolder.ofFloat(View.SCALE_Y, scale, 1f);

    final ObjectAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, alphaPVH, scaleXPVH, scaleYPVH);

    return animation;
}
 
Example 15
Project: LiveGiftLayout   File: GiftFrameLayout.java   Source Code and License Vote up 4 votes
public void firstHideLayout() {
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(GiftFrameLayout.this, alpha);
    animator.setStartDelay(0);
    animator.setDuration(0);
    animator.start();
}
 
Example 16
Project: KokoWalk   File: Ringo.java   Source Code and License Vote up 4 votes
@Override
protected Runnable suicaRunner(final float x1, final float y1, final float x2, final float y2){
    final float attackTime = 0.9f;
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("translationX", x1, x2);
            PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("translationY", y1, y2);
            PropertyValuesHolder holderRotation = PropertyValuesHolder.ofFloat("rotation", 0, 359);

            ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(Ringo.this, holderX, holderY, holderRotation);
            objectAnimator.setDuration(mTime);
            objectAnimator.start();
            Ringo.this.setEnabled(false);
            Ringo.this.setVisibility(View.VISIBLE);
            Ringo.this.setAlpha(0.5f);
            Ringo.this.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Ringo.this.setEnabled(true);
                    Ringo.this.setAlpha(1.0f);
                }
            }, (int) (mTime * 0.5f));

            Ringo.this.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (!Ringo.this.mClicked) {
                        damageButton.callOnClick();
                    }
                    Ringo.this.setEnabled(false);
                    Ringo.this.setAlpha(0.5f);
                }
            }, (int) (mTime * 0.7f));
        }
    };
    return  runnable;
}
 
Example 17
Project: morphos   File: AxisTranslationAnimation.java   Source Code and License Vote up 4 votes
@Override
public Animator buildAnimation(@NonNull ViewDefault viewDefault, @NonNull View viewToMorph, boolean isReversed) {
    float targetValue;
    PropertyValuesHolder[] parameters = new PropertyValuesHolder[1];
    switch (axis) {
        case X:
            if (target == AnimationTarget.TO) {
                if (!isReversed) {
                    initialAxisValue = viewDefault.getX();
                }
                targetValue = isReversed ? initialAxisValue : targetAxisValue;
                viewDefault.setX(targetValue);
            } else {
                targetValue = viewDefault.getX() + (isReversed ? -targetAxisValue : targetAxisValue);
                viewDefault.setX(targetValue);
            }
            parameters[0] = PropertyValuesHolder.ofFloat(X, targetValue);
            break;
        case Y:
            if (target == AnimationTarget.TO) {
                if (!isReversed) {
                    initialAxisValue = viewDefault.getY();
                }
                targetValue = isReversed ? initialAxisValue : targetAxisValue;
                viewDefault.setY(targetValue);
            } else {
                targetValue = viewDefault.getY() + (isReversed ? -targetAxisValue : targetAxisValue);
                viewDefault.setY(targetValue);
            }
            parameters[0] = PropertyValuesHolder.ofFloat(Y, targetValue);
            break;
        case Z:
            if (target == AnimationTarget.TO) {
                if (!isReversed) {
                    initialAxisValue = viewDefault.getZ();
                }
                targetValue = isReversed ? initialAxisValue : targetAxisValue;
                viewDefault.setZ(targetValue);
            } else {
                targetValue = viewDefault.getZ() + (isReversed ? -targetAxisValue : targetAxisValue);
                viewDefault.setZ(targetValue);
            }
            parameters[0] = Morpho.atLeastLollipop ? PropertyValuesHolder.ofFloat(Z, targetValue) : null;
            break;
    }
    if (parameters[0] == null) {
        return null;
    }
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(viewToMorph, parameters);
    if (duration >= 0) {
        animator.setDuration(duration);
    }
    if (interpolator != null) {
        animator.setInterpolator(interpolator);
    }
    return animator;
}
 
Example 18
Project: ArcLayout-master   File: AnimatorUtils.java   Source Code and License Vote up 4 votes
public static PropertyValuesHolder translationX(float... values) {
  return PropertyValuesHolder.ofFloat(TRANSLATION_X, values);
}
 
Example 19
Project: ArcLayout-master   File: AnimatorUtils.java   Source Code and License Vote up 4 votes
public static PropertyValuesHolder scaleY(float... values) {
  return PropertyValuesHolder.ofFloat(SCALE_Y, values);
}
 
Example 20
Project: LiveGiftView   File: GiftAnimationUtils.java   Source Code and License Vote up 3 votes
/**
 * 向上飞 淡出
 *
 * @param target     target
 * @param start      动画起始坐标
 * @param end        动画终止坐标
 * @param alphaFrom  alphaFrom
 * @param alphaTo    alphaTo
 * @param duration   持续时间
 * @param startDelay 延迟时间
 * @return
 */
public static ObjectAnimator createFadeAnimator(View target, float start, float end, float alphaFrom, float alphaTo, int duration, int startDelay) {
    PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", start, end);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", alphaFrom, alphaTo);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, translationY, alpha);
    animator.setStartDelay(startDelay);
    animator.setDuration(duration);
    return animator;
}