本文整理汇总了Java中android.animation.ValueAnimator类的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator类的具体用法?Java ValueAnimator怎么用?Java ValueAnimator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueAnimator类属于android.animation包,在下文中一共展示了ValueAnimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAnim
import android.animation.ValueAnimator; //导入依赖的package包/类
@Override
public void startAnim() {
mAnimator = ValueAnimator.ofFloat(0, 1);
mAnimator.setDuration(mDuration);
mAnimator.setRepeatCount(0);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float factor = (float) animation.getAnimatedValue();
mSweepArg = (int) (90 * factor);
mSecPoint.y = (int) (mFirPoint.y + 2 * MAX_RADIUS_CIRCLE * factor);
}
});
mAnimator.start();
}
示例2: AlbumPictureController
import android.animation.ValueAnimator; //导入依赖的package包/类
public AlbumPictureController(Context context, final ImageSwitcher view, int size) {
this.view = view;
this.size = size;
this.context = context;
this.cache = new BitmapCache(context, BitmapCache.CACHE_ALBUM_VISUALIZER_IMAGE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
defaultColor = context.getColor(R.color.default_play_bg_color);
defaultTextColor = context.getColor(R.color.default_play_text_color);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
defaultColor = context.getResources().getColor(R.color.default_play_bg_color, null);
defaultTextColor = context.getResources().getColor(R.color.default_play_text_color, null);
} else {
defaultColor = context.getResources().getColor(R.color.default_play_bg_color);
defaultTextColor = context.getResources().getColor(R.color.default_play_text_color);
}
this.bitmapProducer = new BitmapProducer(context);
colors = new int[]{
defaultColor,
defaultTextColor,
defaultColor,
defaultTextColor
};
rotateAnim = ObjectAnimator.ofFloat(0, 360);
rotateAnim.setDuration(45 * 1000);
rotateAnim.setRepeatMode(ValueAnimator.RESTART);
rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
rotateAnim.setInterpolator(new LinearInterpolator());
rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
view.getCurrentView().setRotation(value);
}
});
}
示例3: createAnimation
import android.animation.ValueAnimator; //导入依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
int[] durations={960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
int[] delays= {360, 400, 680, 410, 710, -150, -120, 10, 320};
for (int i = 0; i < 9; i++) {
final int index=i;
ValueAnimator alphaAnim=ValueAnimator.ofInt(255, 168,255);
alphaAnim.setDuration(durations[i]);
alphaAnim.setRepeatCount(-1);
alphaAnim.setStartDelay(delays[i]);
alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
alphas[index] = (int) animation.getAnimatedValue();
postInvalidate();
}
});
alphaAnim.start();
animators.add(alphaAnim);
}
return animators;
}
示例4: startAnimation
import android.animation.ValueAnimator; //导入依赖的package包/类
/**
* アニメーションを開始する
*/
public void startAnimation() {
mCenterEdgeAnimator = ValueAnimator.ofFloat(1.f, 0.5f);
mCenterEdgeAnimator.setDuration(100 * SPEED);
mCenterEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);
mLeftEdgeAnimator = ValueAnimator.ofFloat((float) (-0.2 * SQRT_3), 0.f);
mLeftEdgeAnimator.setDuration(100 * SPEED);
mLeftEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);
mRightEdgeAnimator = ValueAnimator.ofFloat(1.f, 0.f);
mRightEdgeAnimator.setDuration(150 * SPEED);
mRightEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);
if (!mPlayed) {
mCenterEdgeAnimator.start();
mLeftEdgeAnimator.start();
mRightEdgeAnimator.start();
} else {
mCenterEdgeAnimator.reverse();
mLeftEdgeAnimator.reverse();
mRightEdgeAnimator.reverse();
}
}
示例5: 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;
}
示例6: upEventDeal
import android.animation.ValueAnimator; //导入依赖的package包/类
/**
* ACTION_UP/ACTION_CANCEL事件处理方法
*/
private void upEventDeal() {
// 1.回调手势解锁监听器Complete方法
if (mGestureLockListener != null) {
mGestureLockListener.onComplete(getPassword());
}
// 2.清除触摸点到最后按下单元点的连线
if (!mPressPoints.isEmpty()) {
mEventX = mPressPoints.get(mPressPoints.size() - 1).x;
mEventY = mPressPoints.get(mPressPoints.size() - 1).y;
}
// 3.提前结束未执行完的动画
if (!mPointAnimators.isEmpty()) {
for (ValueAnimator animator : mPointAnimators) {
animator.end();
}
mPointAnimators.clear();
}
// 4.重绘
postInvalidate();
}
示例7: endAnimation
import android.animation.ValueAnimator; //导入依赖的package包/类
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
super.endAnimation(dynamicWeatherView, listener);
ValueAnimator animator = ValueAnimator.ofFloat(getWidth() - bitmap.getWidth() * 0.25f, getWidth());
animator.setDuration(1000);
animator.setRepeatCount(0);
animator.setInterpolator(new AccelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transFactor = (float) animation.getAnimatedValue();
}
});
if (listener != null) {
animator.addListener(listener);
}
animator.start();
}
示例8: startSunRotate
import android.animation.ValueAnimator; //导入依赖的package包/类
private void startSunRotate() {
ValueAnimator rotateAnim=animMap.get(ANIM_SUN_ROTATE);
if (rotateAnim==null){
rotateAnim =ValueAnimator.ofFloat(0,360f).setDuration(30*1000);
rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
rotateAnim.setInterpolator(new LinearInterpolator());
rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
sunRotateAngle= (float) animation.getAnimatedValue();
}
});
animMap.put(ANIM_SUN_ROTATE,rotateAnim);
}
startValueAnimator(rotateAnim);
}
示例9: createAnimation
import android.animation.ValueAnimator; //导入依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
long[] delays=new long[]{400,200,0,200,400};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
scaleAnim.setDuration(1000);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleYFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.start();
animators.add(scaleAnim);
}
return animators;
}
示例10: startAnim
import android.animation.ValueAnimator; //导入依赖的package包/类
private void startAnim() {
rb_start.setVisibility(View.GONE);
ValueAnimator va = ValueAnimator.ofFloat(0, dp100).setDuration(300);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
float dis = value-lastValue;
iv_back.setX(iv_back.getX()-dis);
iv_finish.setX(iv_finish.getX()+dis);
lastValue = value;
}
});
va.start();
}
示例11: createAnimators
import android.animation.ValueAnimator; //导入依赖的package包/类
private void createAnimators() {
mAnimators = 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(ValueAnimator.INFINITE);
scaleAnim.setStartDelay(delays[i]);
mUpdateListeners.put(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
mAnimators.add(scaleAnim);
}
}
示例12: startBackAnimator
import android.animation.ValueAnimator; //导入依赖的package包/类
/**
* 启动动画 回弹效果
*
*/
private void startBackAnimator() {
PropertyValuesHolder xValuesHolder = PropertyValuesHolder.ofFloat("x", canvasRotateX, 0);
PropertyValuesHolder yValuesHolder = PropertyValuesHolder.ofFloat("y", canvasRotateY, 0);
touchAnimator = ValueAnimator.ofPropertyValuesHolder(xValuesHolder, yValuesHolder).setDuration(700);
touchAnimator.setInterpolator(new BounceInterpolator());
touchAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
canvasRotateY = (Float) animation.getAnimatedValue("y");
canvasRotateX = (Float) animation.getAnimatedValue("x");
invalidate();
}
});
touchAnimator.start();
}
示例13: onCreateAnimators
import android.animation.ValueAnimator; //导入依赖的package包/类
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
ArrayList<ValueAnimator> 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]);
addUpdateListener(scaleAnim, animation -> {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
});
animators.add(scaleAnim);
}
return animators;
}
示例14: setupValues
import android.animation.ValueAnimator; //导入依赖的package包/类
public UDAnimatorSet setupValues(Animator animator) {
animator.setupStartValues();
if (mTarget != null && mAnimators != null) {
for (Animator anim : mAnimators) {
anim.setTarget(mTarget.getView());
anim.setupStartValues();
if (anim instanceof ValueAnimator) {
((ValueAnimator) anim).setRepeatCount(mRepeatCount);
((ValueAnimator) anim).setRepeatMode(mRepeatMode);
//TODO
}
}
if (animator instanceof AnimatorSet) {
((AnimatorSet) animator).playTogether(mAnimators);
}
}
return this;
}
示例15: 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;
}