本文整理汇总了Java中android.animation.ObjectAnimator.addUpdateListener方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectAnimator.addUpdateListener方法的具体用法?Java ObjectAnimator.addUpdateListener怎么用?Java ObjectAnimator.addUpdateListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ObjectAnimator
的用法示例。
在下文中一共展示了ObjectAnimator.addUpdateListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spin
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* Applys a spin animation to the Chart.
*
* @param durationmillis
* @param fromangle
* @param toangle
*/
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {
if (android.os.Build.VERSION.SDK_INT < 11)
return;
setRotationAngle(fromangle);
ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
toangle);
spinAnimator.setDuration(durationmillis);
spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));
spinAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
postInvalidate();
}
});
spinAnimator.start();
}
示例2: startScaleAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void startScaleAnimation() {
ObjectAnimator animator=ObjectAnimator.ofFloat(this,"xxx",0,1).setDuration(300);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float progress= (float) animation.getAnimatedValue();
//当progress<0.5f就放大,否则缩小
if(progress<0.5f){
setScaleX(1+progress*THRESHOLD*2);
setScaleY(1+progress*THRESHOLD*2);
}else{
setScaleX(1+THRESHOLD-(progress-0.5f)*2*THRESHOLD);
setScaleY(1+THRESHOLD-(progress-0.5f)*2*THRESHOLD);
}
}
});
animator.start();
}
示例3: unselectMenu
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public void unselectMenu(){
tvMenu.setVisibility(VISIBLE);
ivIcon.setImageResource(normalIconId);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(null,"xxx",1,0).setDuration(300);
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float progress = (float) animation.getAnimatedValue();
setPivotX(getWidth()/2);
setPivotY(0);
setScaleX(1+progress*THRESHOLD);
setScaleY(1+progress*THRESHOLD);
}
});
objectAnimator.start();
}
示例4: selectMenu
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public void selectMenu(){
tvMenu.setVisibility(INVISIBLE);
ivIcon.setImageResource(selectIconId);
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(null,"xxx",0,1).setDuration(300);
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float progress = (float) animation.getAnimatedValue();
setPivotX(getWidth()/2);
setPivotY(0);
setScaleX(1+progress*THRESHOLD);
setScaleY(1+progress*THRESHOLD);
}
});
objectAnimator.start();
}
示例5: smoothScrollTo
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void smoothScrollTo(int desX, int desY, AnimatorListener listener)
{
ObjectAnimator xTranslate = ObjectAnimator.ofInt(this, "scrollX", desX);
ObjectAnimator yTranslate = ObjectAnimator.ofInt(this, "scrollY", desY);
yTranslate.addUpdateListener(new AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
if (mHeaderStatusChangedListener != null) mHeaderStatusChangedListener.onHeaderOffsetChanged((int) (mScrollOffsetHeight * animation.getAnimatedFraction()), animation.getAnimatedFraction());
}
});
AnimatorSet animators = new AnimatorSet();
animators.setDuration(240L);
animators.playTogether(xTranslate, yTranslate);
if (listener != null) animators.addListener(listener);
animators.start();
}
示例6: startSaturationAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void startSaturationAnimation(Context context, final AppCompatImageView target) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
target.setHasTransientState(true);
final AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();
final ObjectAnimator saturation = ObjectAnimator.ofFloat(
matrix, AnimUtils.ObservableColorMatrix.SATURATION, 0f, 1f);
saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
target.setColorFilter(new ColorMatrixColorFilter(matrix));
}
});
saturation.setDuration(2000);
saturation.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(context));
saturation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
target.clearColorFilter();
target.setHasTransientState(false);
}
});
saturation.start();
}
}
示例7: getDisappearAnimator
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@SuppressLint("ObjectAnimatorBinding")
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);
@SuppressLint("ObjectAnimatorBinding") PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
this, radiusDisappear, fadeOut).setDuration(duration);
disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
return disappearAnimator;
}
示例8: getReappearAnimator
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public ObjectAnimator getReappearAnimator() {
if (!mIsInitialized || !mDrawValuesReady) {
Log.e(TAG, "RadialSelectorView was not ready for animation.");
return null;
}
Keyframe kf0, kf1, kf2, kf3;
float midwayPoint = 0.2f;
int duration = 500;
// The time points are half of what they would normally be, because this animation is
// staggered against the disappear so they happen seamlessly. The reappear starts
// halfway into the disappear.
float delayMultiplier = 0.25f;
float transitionDurationMultiplier = 1f;
float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
int totalDuration = (int) (duration * totalDurationMultiplier);
float delayPoint = (delayMultiplier * duration) / totalDuration;
midwayPoint = 1 - (midwayPoint * (1 - delayPoint));
kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier);
kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier);
kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
kf3 = Keyframe.ofFloat(1f, 1);
PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe(
"animationRadiusMultiplier", kf0, kf1, kf2, kf3);
kf0 = Keyframe.ofFloat(0f, 0f);
kf1 = Keyframe.ofFloat(delayPoint, 0f);
kf2 = Keyframe.ofFloat(1f, 1f);
@SuppressLint("ObjectAnimatorBinding") PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
this, radiusReappear, fadeIn).setDuration(totalDuration);
reappearAnimator.addUpdateListener(mInvalidateUpdateListener);
return reappearAnimator;
}
示例9: animateX
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* Animates the rendering of the chart on the x-axis with the specified
* animation time. If animate(...) is called, no further calling of
* invalidate() is necessary to refresh the chart.
*
* @param durationMillis
* @param easing
*/
public void animateX(int durationMillis, EasingFunction easing) {
if (android.os.Build.VERSION.SDK_INT < 11)
return;
ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f);
animatorX.setInterpolator(easing);
animatorX.setDuration(durationMillis);
animatorX.addUpdateListener(mListener);
animatorX.start();
}
示例10: animateY
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
/**
* Animates the rendering of the chart on the y-axis with the specified
* animation time. If animate(...) is called, no further calling of
* invalidate() is necessary to refresh the chart.
*
* @param durationMillis
* @param easing
*/
public void animateY(int durationMillis, EasingFunction easing) {
if (android.os.Build.VERSION.SDK_INT < 11)
return;
ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
animatorY.setInterpolator(easing);
animatorY.setDuration(durationMillis);
animatorY.addUpdateListener(mListener);
animatorY.start();
}
示例11: animateHeartButton
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void animateHeartButton(final RecipesAdapter.RecipeViewHolder holder) {
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator rotation = ObjectAnimator.ofFloat(holder.likeButton, "rotation", 0.0f, 360.0f);
rotation.setDuration(800);
rotation.setInterpolator(ANTICIPATE_OVERSHOOT_INTERPOLATOR);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(holder.likeButton, "scaleX", 1.0f, 1.5f, 1.0f);
scaleX.setDuration(800);
scaleX.setInterpolator(ANTICIPATE_OVERSHOOT_INTERPOLATOR);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(holder.likeButton, "scaleY", 1.0f, 1.5f, 1.0f);
scaleY.setDuration(800);
scaleY.setInterpolator(ANTICIPATE_OVERSHOOT_INTERPOLATOR);
rotation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator valueAnimator) {
if (valueAnimator.getCurrentPlayTime() >= 500) {
holder.likeButton.setImageResource(R.drawable.ic_favorite_higlighted_24dp);
}
}
});
animatorSet.playTogether(rotation, scaleX, scaleY);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
dispatchAnimationFinished(holder);
}
});
animatorSet.start();
}
示例12: prepareStateChange
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override
public void prepareStateChange(State toState, AnimatorSet targetAnim) {
int finalAlpha = getAlphaForState(toState);
if (targetAnim == null) {
mBgPaint.setAlpha(finalAlpha);
invalidate();
} else {
ObjectAnimator anim = ObjectAnimator.ofArgb(mBgPaint, "alpha", finalAlpha);
anim.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
invalidate();
}
});
targetAnim.play(anim);
}
}
示例13: leftchange
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public void leftchange(View view) {
ObjectAnimator animator = ObjectAnimator.ofFloat(mColorTextView,"progress",0,1);
animator.setDuration(2000).start();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
mColorTextView.setprogress(value,ColorTextView.DEC_LEFT);
}
});
}
示例14: getViewTranslationAnimator
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private Animator getViewTranslationAnimator(View v, float target,
AnimatorUpdateListener listener) {
ObjectAnimator anim = createTranslationAnimation(v, target);
if (listener != null) {
anim.addUpdateListener(listener);
}
return anim;
}
示例15: addOnUpdateListener
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void addOnUpdateListener(ObjectAnimator animator) {
if (animator != null && mOnUpdateCallback != null) {
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
LuaUtil.callFunction(mOnUpdateCallback);
}
});
}
}