android.animation.PropertyValuesHolder源码实例Demo

类android.animation.PropertyValuesHolder源码实例Demo

下面列出了android.animation.PropertyValuesHolder 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LiveGiftLayout   文件: CustormAnim.java
@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;
    }
 
@NonNull
@Override
public AnimatorSet createAnimator() {
  MotionSpec spec = getCurrentMotionSpec();
  if (spec.hasPropertyValues("width")) {
    PropertyValuesHolder[] widthValues = spec.getPropertyValues("width");
    widthValues[0].setFloatValues(getWidth(), size.getWidth());
    spec.setPropertyValues("width", widthValues);
  }

  if (spec.hasPropertyValues("height")) {
    PropertyValuesHolder[] heightValues = spec.getPropertyValues("height");
    heightValues[0].setFloatValues(getHeight(), size.getHeight());
    spec.setPropertyValues("height", heightValues);
  }

  return super.createAnimator(spec);
}
 
源代码3 项目: Flubber   文件: Swing.java
@Override
public Animator getAnimationFor(AnimationBody animationBody, View view) {
    final float force = animationBody.getForce();

    float[] values = {
            (float) Math.toDegrees(0),
            (float) Math.toDegrees(0.3f * force),
            (float) Math.toDegrees(-0.3f * force),
            (float) Math.toDegrees(0.3f * force),
            (float) Math.toDegrees(0f),
            (float) Math.toDegrees(0f)
    };

    final PropertyValuesHolder pvhRotation =
            PropertyValuesHolder.ofKeyframe(View.ROTATION, KeyFrameUtil.getKeyFrames(Flubber.FRACTIONS, values));

    final ObjectAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, pvhRotation);

    return animation;
}
 
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
源代码5 项目: android_9.0.0_r45   文件: DragState.java
private ValueAnimator createCancelAnimationLocked() {
    final ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder(
            PropertyValuesHolder.ofFloat(
                    ANIMATED_PROPERTY_X, mCurrentX - mThumbOffsetX, mCurrentX),
            PropertyValuesHolder.ofFloat(
                    ANIMATED_PROPERTY_Y, mCurrentY - mThumbOffsetY, mCurrentY),
            PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_SCALE, 1, 0),
            PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_ALPHA, mOriginalAlpha, 0));
    final AnimationListener listener = new AnimationListener();
    animator.setDuration(MIN_ANIMATION_DURATION_MS);
    animator.setInterpolator(mCubicEaseOutInterpolator);
    animator.addListener(listener);
    animator.addUpdateListener(listener);

    mService.mAnimationHandler.post(() -> animator.start());
    return animator;
}
 
源代码6 项目: android_9.0.0_r45   文件: FragmentManager.java
static boolean modifiesAlpha(Animator anim) {
    if (anim == null) {
        return false;
    }
    if (anim instanceof ValueAnimator) {
        ValueAnimator valueAnim = (ValueAnimator) anim;
        PropertyValuesHolder[] values = valueAnim.getValues();
        for (int i = 0; i < values.length; i++) {
            if (("alpha").equals(values[i].getPropertyName())) {
                return true;
            }
        }
    } else if (anim instanceof AnimatorSet) {
        List<Animator> animList = ((AnimatorSet) anim).getChildAnimations();
        for (int i = 0; i < animList.size(); i++) {
            if (modifiesAlpha(animList.get(i))) {
                return true;
            }
        }
    }
    return false;
}
 
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@Override
public ObjectAnimator getAppearingAnimator(Context context){

    final Point outPoint = new Point();
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    wm.getDefaultDisplay().getSize(outPoint);

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(new Object(),
            PropertyValuesHolder.ofFloat("alpha", 0.f, 1.f),
            PropertyValuesHolder.ofFloat("translationY", outPoint.y / 2.f, 0.f),
            PropertyValuesHolder.ofFloat("rotation", -45.f, 0.f));

    animator.setDuration((long) (200 * mSpeedFactor));
    return animator;
}
 
源代码8 项目: SublimePicker   文件: RadialTimePickerView.java
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
源代码9 项目: Android-Image-Slider   文件: ScaleDownAnimation.java
@NonNull
@Override
protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) {
	String propertyName;
	int startRadiusValue;
	int endRadiusValue;

	if (isReverse) {
		propertyName = ANIMATION_SCALE_REVERSE;
		startRadiusValue = (int) (radius * scaleFactor);
		endRadiusValue = radius;
	} else {
		propertyName = ANIMATION_SCALE;
		startRadiusValue = radius;
		endRadiusValue = (int) (radius * scaleFactor);
	}

	PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
	holder.setEvaluator(new IntEvaluator());

	return holder;
}
 
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
源代码11 项目: Android-Image-Slider   文件: ScaleAnimation.java
@NonNull
protected PropertyValuesHolder createScalePropertyHolder(boolean isReverse) {
    String propertyName;
    int startRadiusValue;
    int endRadiusValue;

    if (isReverse) {
        propertyName = ANIMATION_SCALE_REVERSE;
        startRadiusValue = radius;
        endRadiusValue = (int) (radius * scaleFactor);
    } else {
        propertyName = ANIMATION_SCALE;
        startRadiusValue = (int) (radius * scaleFactor);
        endRadiusValue = radius;
    }

    PropertyValuesHolder holder = PropertyValuesHolder.ofInt(propertyName, startRadiusValue, endRadiusValue);
    holder.setEvaluator(new IntEvaluator());

    return holder;
}
 
源代码12 项目: XPlayer2   文件: LiveRoomActivity.java
private void scale(float ratio) {
    if (scaleRatio == ratio) {
        return;
    }

    if (scaleAnimator != null) {
        scaleAnimator.cancel();
    }

    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", scaleRatio, ratio);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", scaleRatio, ratio);
    PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat("translationX", 0);
    PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0);
    scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mVideoView, scaleX, scaleY, translationX, translationY);
    scaleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            animation.removeAllListeners();
            scaleAnimator = null;
        }
    });
    scaleAnimator.setDuration(150L).start();
    scaleRatio = ratio;
}
 
源代码13 项目: Android-SecretCodes   文件: MainActivity.java
private static ObjectAnimator tada(final View view, final float shakeFactor) {
    final PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f),
            Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f),
            Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f));

    final PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f),
            Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f),
            Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f));

    final PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f),
            Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor), Keyframe.ofFloat(.3f, 3f * shakeFactor),
            Keyframe.ofFloat(.4f, -3f * shakeFactor), Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor),
            Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor), Keyframe.ofFloat(.9f, 3f * shakeFactor),
            Keyframe.ofFloat(1f, 0));

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1000);
}
 
源代码14 项目: Blackbulb   文件: RadialSelectorView.java
public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }

    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;

    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
            "animationRadiusMultiplier", kf0, kf1, kf2);

    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);

    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
            this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);

    return disappearAnimator;
}
 
private void createNextAnimation(boolean start) {
    float startX = mImageView.getTranslationX();
    float startY = mImageView.getTranslationY();
    float endX = -mRandom.nextInt(mAnimationRange);
    float endY = -mRandom.nextInt(mAnimationRange);
    float distance = (float) Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));

    mAnimation = ObjectAnimator.ofPropertyValuesHolder(mImageView,
            PropertyValuesHolder.ofFloat("translationX", startX, endX),
            PropertyValuesHolder.ofFloat("translationY", startY, endY));
    mAnimation.setInterpolator(new AccelerateDecelerateInterpolator());

    mAnimation.setDuration(Math.max(BASE_ANIMATION_DURATION_MS / 10,
            (int) (distance * BASE_ANIMATION_DURATION_MS / mAnimationRange)));

    mAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            createNextAnimation(true);
        }
    });
    if (start) {
        mAnimation.start();
    }
}
 
源代码16 项目: NBAPlus   文件: Tooltip.java
/**
 *
 * @param values
 * @return
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public ObjectAnimator setEnterAnimation(PropertyValuesHolder... values){

    for(PropertyValuesHolder value: values){

        if(value.getPropertyName().equals("alpha"))
            setAlpha(0);
        if(value.getPropertyName().equals("rotation"))
            setRotation(0);
        if(value.getPropertyName().equals("rotationX"))
            setRotationX(0);
        if(value.getPropertyName().equals("rotationY"))
            setRotationY(0);
        if(value.getPropertyName().equals("translationX"))
            setTranslationX(0);
        if(value.getPropertyName().equals("translationY"))
            setTranslationY(0);
        if(value.getPropertyName().equals("scaleX"))
            setScaleX(0);
        if(value.getPropertyName().equals("scaleY"))
            setScaleY(0);
    }
    return mEnterAnimator =  ObjectAnimator.ofPropertyValuesHolder(this, values);
}
 
@Override
public SkinAnimator apply(@NonNull final View view, @Nullable final Action action) {
    animator = ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofFloat("alpha", 1, 0),
            PropertyValuesHolder.ofFloat("translationY", 0, view.getHeight()));
    animator.setDuration(3 * PRE_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            resetView(view);
            if (action != null) {
                action.action();
            }
        }
    });
    return this;
}
 
源代码18 项目: Kernel-Tuner   文件: FragmentTransactionExtended.java
public void slideForward() {
    View movingFragmentView = mFirstFragment.getView();
    PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationX", 40f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1f);
    ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY, alpha);

    ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationX", 0);
    movingFragmentRotator.setStartDelay(mContext.getResources().getInteger(R.integer.half_slide_up_down_duration));

    AnimatorSet s = new AnimatorSet();
    s.playTogether(movingFragmentAnimator, movingFragmentRotator);
    s.setStartDelay(mContext.getResources().getInteger(R.integer.slide_up_down_duration));
    s.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mIsAnimating = false;
            mDidSlideOut = true;
        }
    });
    s.start();
    ((Activity) this.mContext).getFragmentManager().removeOnBackStackChangedListener(this);
}
 
源代码19 项目: AndroidSkinAnimator   文件: TranslationAnimator2.java
@Override
public SkinAnimator apply(@NonNull View view, @Nullable final Action action) {
    this.targetView = view;
    preAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft(), view.getRight()))
            .setDuration(PRE_DURATION * 3);
    preAnimator.setInterpolator(new AccelerateInterpolator());
    afterAnimator = ObjectAnimator.ofPropertyValuesHolder(targetView,
            PropertyValuesHolder.ofFloat("translationX",
                    view.getLeft() - view.getWidth(), view.getLeft()))
            .setDuration(AFTER_DURATION * 3);
    afterAnimator.setInterpolator(new BounceInterpolator());

    preAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (action != null) {
                action.action();
            }
            afterAnimator.start();
        }
    });
    return this;
}
 
源代码20 项目: MD360Player4Android   文件: MD360PlayerActivity.java
private void startCameraAnimation(final MDDirectorCamUpdate cameraUpdate, PropertyValuesHolder... values){
    if (animator != null){
        animator.cancel();
    }

    animator = ValueAnimator.ofPropertyValuesHolder(values).setDuration(2000);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float near = (float) animation.getAnimatedValue("near");
            float eyeZ = (float) animation.getAnimatedValue("eyeZ");
            float pitch = (float) animation.getAnimatedValue("pitch");
            float yaw = (float) animation.getAnimatedValue("yaw");
            float roll = (float) animation.getAnimatedValue("roll");
            cameraUpdate.setEyeZ(eyeZ).setNearScale(near).setPitch(pitch).setYaw(yaw).setRoll(roll);
        }
    });
    animator.start();
}
 
源代码21 项目: YCGallery   文件: EnterScreenAnimations.java
/**
 * This method creates an animator that changes ImageView position on the screen.
 * It will look like view is translated from its position on previous screen to its new position on this screen
 */
@NonNull
private ObjectAnimator createEnteringImagePositionAnimator() {
    PropertyValuesHolder propertyLeft = PropertyValuesHolder.ofInt("left", mAnimatedImage.getLeft(), mToLeft);
    PropertyValuesHolder propertyTop = PropertyValuesHolder.ofInt("top", mAnimatedImage.getTop(), mToTop - getStatusBarHeight());

    PropertyValuesHolder propertyRight = PropertyValuesHolder.ofInt("right", mAnimatedImage.getRight(), mToLeft + mToWidth);
    PropertyValuesHolder propertyBottom = PropertyValuesHolder.ofInt("bottom", mAnimatedImage.getBottom(), mToTop + mToHeight - getStatusBarHeight());

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mAnimatedImage, propertyLeft, propertyTop, propertyRight, propertyBottom);
    animator.addListener(new SimpleAnimationListener() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // set new parameters of animated ImageView. This will prevent blinking of view when set visibility to visible in Exit animation
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mAnimatedImage.getLayoutParams();
            layoutParams.height = mImageTo.getHeight();
            layoutParams.width = mImageTo.getWidth();
            layoutParams.setMargins(mToLeft, mToTop - getStatusBarHeight(), 0, 0);
        }
    });
    return animator;
}
 
源代码22 项目: scene   文件: AbsoluteChangeBounds.java
@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }

    final View view = endValues.view;
    sceneRoot.getLocationInWindow(tempLocation);
    int startX = (Integer) startValues.values.get(PROPNAME_WINDOW_X) - tempLocation[0];
    int startY = (Integer) startValues.values.get(PROPNAME_WINDOW_Y) - tempLocation[1];
    int endX = (Integer) endValues.values.get(PROPNAME_WINDOW_X) - tempLocation[0];
    int endY = (Integer) endValues.values.get(PROPNAME_WINDOW_Y) - tempLocation[1];
    // TODO: also handle size changes: check bounds and animate size changes
    if (startX != endX || startY != endY) {
        final int width = view.getWidth();
        final int height = view.getHeight();
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        final BitmapDrawable drawable = new BitmapDrawable(bitmap);
        view.setAlpha(0);
        drawable.setBounds(startX, startY, startX + width, startY + height);
        sceneRoot.getOverlay().add(drawable);
        Path topLeftPath = getPathMotion().getPath(startX, startY, endX, endY);
        PropertyValuesHolder origin = PropertyValuesHolder.ofObject(
                DRAWABLE_ORIGIN_PROPERTY, null, topLeftPath);
        ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(drawable, origin);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                sceneRoot.getOverlay().remove(drawable);
                view.setAlpha(1);
            }
        });
        return anim;
    }
    return null;
}
 
源代码23 项目: Flubber   文件: Wobble.java
private Animator getShake(AnimationBody animationBody, View view) {
    final float dX = DimensionUtils.dp2px(30);
    final float force = animationBody.getForce();

    float[] translationValues = {0f, (dX * force), (-dX * force), (dX * force), 0f, 0f};
    final PropertyValuesHolder translationPVH =
            PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, KeyFrameUtil.getKeyFrames(FRACTIONS, translationValues));

    final ObjectAnimator animation =
            ObjectAnimator.ofPropertyValuesHolder(view, translationPVH);

    animation.setInterpolator(getInterpolatorProvider().createInterpolatorFor(animationBody));

    return animation;
}
 
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
@Override
public ObjectAnimator getInitalAnimator(Context context){

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(new Object(),
            PropertyValuesHolder.ofFloat("alpha", 0.5f, 1.f),
            PropertyValuesHolder.ofFloat("rotation", 60.f, 0.f));

    animator.setDuration((long) (200 * mSpeedFactor));
    return animator;
}
 
源代码25 项目: UltimateAndroid   文件: DefaultAnimationHandler.java
@Override
public void animateMenuOpening(Point center) {
    super.animateMenuOpening(center);

    setAnimating(true);

    Animator lastAnimation = null;
    for (int i = 0; i < menu.getSubActionItems().size(); i++) {

        menu.getSubActionItems().get(i).view.setScaleX(0);
        menu.getSubActionItems().get(i).view.setScaleY(0);
        menu.getSubActionItems().get(i).view.setAlpha(0);

        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, 1);
        PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
        PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1);

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

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

        // Put a slight lag between each of the menu items to make it asymmetric
        animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
        animation.start();
    }
    if(lastAnimation != null) {
        lastAnimation.addListener(new LastAnimationListener());
    }

}
 
源代码26 项目: android_9.0.0_r45   文件: FastScroller.java
/**
 * Returns an animator for the view's bounds.
 */
private static Animator animateBounds(View v, Rect bounds) {
    final PropertyValuesHolder left = PropertyValuesHolder.ofInt(LEFT, bounds.left);
    final PropertyValuesHolder top = PropertyValuesHolder.ofInt(TOP, bounds.top);
    final PropertyValuesHolder right = PropertyValuesHolder.ofInt(RIGHT, bounds.right);
    final PropertyValuesHolder bottom = PropertyValuesHolder.ofInt(BOTTOM, bounds.bottom);
    return ObjectAnimator.ofPropertyValuesHolder(v, left, top, right, bottom);
}
 
源代码27 项目: Trebuchet   文件: LauncherAnimUtils.java
public static ObjectAnimator ofPropertyValuesHolder(Object target,
        View view, PropertyValuesHolder... values) {
    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(target);
    anim.setValues(values);
    cancelOnDestroyActivity(anim);
    new FirstFrameAnimatorHelper(anim, view);
    return anim;
}
 
源代码28 项目: Interessant   文件: Pop.java
@Override
public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
                         TransitionValues endValues) {
    view.setAlpha(0f);
    view.setScaleX(0f);
    view.setScaleY(0f);
    return ObjectAnimator.ofPropertyValuesHolder(
            view,
            PropertyValuesHolder.ofFloat(View.ALPHA, 1f),
            PropertyValuesHolder.ofFloat(View.SCALE_X, 1f),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f));
}
 
@Override
public void animateMenuClosing(Point center) {
    super.animateMenuClosing(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)-DIST);
        PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, -730);
        PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X,2, 1,0);
        PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y,2, 1,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((i) * LAG_BETWEEN_ITEMS);
        animation.start();
    }
    if(lastAnimation != null) {
        lastAnimation.addListener(new LastAnimationListener());
    }
}
 
源代码30 项目: weex-uikit   文件: WXAnimationBean.java
private void initHolders(){
  for (Map.Entry<Property<View, Float>, Float> entry : transformMap.entrySet()) {
    holders.add(PropertyValuesHolder.ofFloat(entry.getKey(), entry.getValue()));
  }
  if (!TextUtils.isEmpty(opacity)) {
    holders.add(PropertyValuesHolder.ofFloat(View.ALPHA, WXUtils.fastGetFloat(opacity, 3)));
  }
}