本文整理汇总了Java中android.animation.ValueAnimator.addUpdateListener方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.addUpdateListener方法的具体用法?Java ValueAnimator.addUpdateListener怎么用?Java ValueAnimator.addUpdateListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.addUpdateListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAlphaAnim
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public static void startAlphaAnim(@NonNull final View view, int duration, @Nullable Animator.AnimatorListener listener, float... values) {
ValueAnimator alphaAnim = ObjectAnimator.ofFloat(values);
alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float alpha = (float) animation.getAnimatedValue();
view.setAlpha(alpha);
}
});
if (listener != null) {
alphaAnim.addListener(listener);
}
alphaAnim.setDuration(duration);
alphaAnim.start();
}
示例2: endAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
super.endAnimation(dynamicWeatherView, listener);
ValueAnimator animator = ValueAnimator.ofFloat(1, -1);
animator.setDuration(1000);
animator.setRepeatCount(0);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
hillTransFactor = (float) animation.getAnimatedValue();
}
});
if (listener != null) {
animator.addListener(listener);
}
animator.start();
}
示例3: createBallJumpAnimators
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public ArrayList<ValueAnimator> createBallJumpAnimators() {
ArrayList<ValueAnimator> animators = new ArrayList<>();
int[] delays = new int[]{70, 140, 210};
for (int i = 0; i < 3; i++) {
final int index = i;
ValueAnimator scaleAnim = ValueAnimator.ofFloat(mTextBottomBorder, mTextBottomBorder - mBallRadius * 2, mTextBottomBorder);
scaleAnim.setDuration(600);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
translateYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
animators.add(scaleAnim);
}
return animators;
}
示例4: releaseView
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void releaseView() {
if (mAnimator==null){
final ValueAnimator valAnimator=ValueAnimator.ofFloat(mPercent,0f);
valAnimator.setDuration(500);
valAnimator.setInterpolator(new OvershootInterpolator());
valAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animValue= (float) valAnimator.getAnimatedValue();
setPercent(animValue);
}
});
this.mAnimator=valAnimator;
}else {
mAnimator.cancel();
mAnimator.setFloatValues(mPercent,0f);
}
mAnimator.start();
}
示例5: getAnimators
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> getAnimators() {
final List<Animator> animations = new ArrayList<>();
calculate();
if (mCameraDistance != null) {
final ValueAnimator animator = ValueAnimator.ofFloat(mCurrentCameraDistance, mCameraDistance);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
viewToMove.setCameraDistance((float) valueAnimator.getAnimatedValue());
}
});
animations.add(animator);
}
return animations;
}
示例6: createMoveValueAnimator
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 关注3:设置旋转动画
*/
private ValueAnimator createMoveValueAnimator() {
// 通过属性动画进行设置
ValueAnimator moveAnim = ValueAnimator.ofFloat(0, 90).setDuration(moveSpeed);
moveAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Object animatedValue = animation.getAnimatedValue();
// 赋值
mRotateDegree = (float) animatedValue;
// 更新视图
invalidate();
}
});
return moveAnim;
}
示例7: setUpAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override public void setUpAnimation() {
for (int i = 0; i < numberOfLine; i++) {
final int index = i;
ValueAnimator fadeAnimator = ValueAnimator.ofInt(126, 255, 126);
fadeAnimator.setRepeatCount(ValueAnimator.INFINITE);
fadeAnimator.setDuration(1000);
fadeAnimator.setStartDelay(index * 120);
fadeAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override public void onAnimationUpdate(ValueAnimator animation) {
lines[index].setAlpha((int)animation.getAnimatedValue());
if (invalidateListener != null) {
invalidateListener.reDraw();
}
}
});
fadeAnimator.start();
}
}
示例8: getBezierValueAnimator
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private ValueAnimator getBezierValueAnimator(LeafHolder target, RectF leafFlyRect, float progress) {
BezierEvaluator evaluator = new BezierEvaluator(getPoint1(leafFlyRect), getPoint2(leafFlyRect));
int leafFlyStartY = (int) (mCurrentProgressBounds.bottom - mLeafDrawable.getIntrinsicHeight());
int leafFlyRange = (int) (mCurrentProgressBounds.height() - mLeafDrawable.getIntrinsicHeight());
int startPointY = leafFlyStartY - mRandom.nextInt(leafFlyRange);
int endPointY = leafFlyStartY - mRandom.nextInt(leafFlyRange);
ValueAnimator animator = ValueAnimator.ofObject(evaluator,
new PointF((int) (leafFlyRect.right - mLeafDrawable.getIntrinsicWidth()), startPointY),
new PointF(leafFlyRect.left, endPointY));
animator.addUpdateListener(new BezierListener(target));
animator.setTarget(target);
animator.setDuration((long) ((mRandom.nextInt(300) + mDuration * DEFAULT_LEAF_FLY_DURATION_FACTOR) * (1.0f - progress)));
return animator;
}
示例9: createAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public List<Animator> createAnimation() {
List<Animator> animators = new ArrayList<>();
int[] delays = new int[]{120, 240, 360};
for (int i = 0; i < 3; i++) {
final int index = i;
ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);
scaleAnim.setDuration(750);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.start();
animators.add(scaleAnim);
}
return animators;
}
示例10: colorAnimateImageView
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void colorAnimateImageView() {
final int activatedColor = context.getResources().getColor(R.color.like_icon_activated);
final ValueAnimator colorAnim = !isLiked ? ObjectAnimator.ofFloat(0f, 1f)
: ObjectAnimator.ofFloat(1f, 0f);
colorAnim.setDuration(ANIMATION_DURATION);
colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float mul = (Float) animation.getAnimatedValue();
int alpha = adjustAlpha(activatedColor, mul);
likesImageView.setColorFilter(alpha, PorterDuff.Mode.SRC_ATOP);
if (mul == 0.0) {
likesImageView.setColorFilter(null);
}
}
});
colorAnim.start();
}
示例11: revealSides
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@OnClick({R.id.first,R.id.third})
public void revealSides(FloatingActionButton dot) {
if (finished) {
finished=false;
lastDot = dot;
float deltaX = topPanel.getWidth() / 2 - dot.getX() - dot.getWidth() / 2;
float deltaY = topPanel.getHeight() / 2 - dot.getY() - dot.getHeight() / 2;
deltaY -= topPanel.getHeight() / 2 + getResources().getDimension(R.dimen.morph_radius) / 4;
Path arcPath = createArcPath(dot, deltaX, deltaY, -deltaX);
ValueAnimator pathAnimator = ValueAnimator.ofFloat(0, 1);
pathAnimator.addUpdateListener(new ArcListener(arcPath, dot));
int dotColor=dot.getBackgroundTintList().getDefaultColor();
topPanel.setBackgroundColor(dotColor);
if(dotColor==color) {
backgroundReveal().start();
}
pathAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
Animator animator = createRevealAnimator(dot, 0);
finish(animator);
animator.start();
runCloseAnimation();
}
});
AnimatorSet animatorSet = morphParent(duration(R.integer.reveal_duration));
animatorSet.play(pathAnimator);
addScaleAnimation(duration(R.integer.short_delay), duration(R.integer.fade_duration), animatorSet);
animatorSet.start();
}
}
示例12: animateRevealHide
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void animateRevealHide(final View viewRoot) {
View fab = MainActivity.of(getActivity()).fab;
int cx = fab.getLeft() + (fab.getWidth()/2); //middle of button
int cy = fab.getTop() + (fab.getHeight()/2); //middle of button
int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left
Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, radius, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
viewRoot.setVisibility(View.INVISIBLE);
}
});
//anim.setInterpolator(new AccelerateInterpolator());
anim.setDuration(Navigator.ANIM_DURATION);
anim.start();
Integer colorTo = getResources().getColor(R.color.primaryColor);
Integer colorFrom = getResources().getColor(android.R.color.white);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
overlayLayout.setBackgroundColor((Integer)animator.getAnimatedValue());
}
});
colorAnimation.setInterpolator(new AccelerateInterpolator(2));
colorAnimation.setDuration(Navigator.ANIM_DURATION);
colorAnimation.start();
}
示例13: createFabIconTintAnimator
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@NonNull
private ValueAnimator createFabIconTintAnimator(int[] colors) {
ValueAnimator anim = newArgbValueAnimator(colors);
anim.setDuration(FAB_ANIM_DURATION);
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
DrawableCompat.setTintList(mOkButton.getDrawable(), ColorStateList.valueOf(
(int) animation.getAnimatedValue()));
}
});
return anim;
}
示例14: crossFade
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void crossFade(int duration) {
ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f);
va.setDuration(duration);
va.setInterpolator(new DecelerateInterpolator(1.5f));
va.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mCrossFadeProgress = animation.getAnimatedFraction();
invalidate();
}
});
va.start();
}
示例15: animateAlphaAtIndex
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Returns an animator which changes the alpha at the index {@param index}
* to {@param finalAlpha}. Alphas at other index are not affected.
*/
public Animator animateAlphaAtIndex(float finalAlpha, final int index) {
final ValueAnimator anim;
if (Float.compare(finalAlpha, mAlphas[index]) == 0) {
// Return a dummy animator to avoid null checks.
anim = ValueAnimator.ofFloat(0, 0);
} else {
ValueAnimator animator = ValueAnimator.ofFloat(mAlphas[index], finalAlpha);
animator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = (Float) valueAnimator.getAnimatedValue();
setAlphaAtIndex(value, index);
}
});
anim = animator;
}
if (Float.compare(finalAlpha, 0f) == 0) {
// In case when any channel is animating to 0, and the current alpha is also 0, do not
// update alpha of the target view while the animation is running.
// We special case '0' because if any channel is set to 0, values of other
// channels do not matter.
anim.addListener(new ZeroAlphaAnimatorListener());
}
return anim;
}