本文整理汇总了Java中android.animation.ValueAnimator.ofFloat方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.ofFloat方法的具体用法?Java ValueAnimator.ofFloat怎么用?Java ValueAnimator.ofFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.ofFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expand
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void expand() {
mExpanded = true;
if (mArrow != null) {
mArrow.animate().rotationX(0).setDuration(500).start();
if (mAnimator != null) {
mAnimator.cancel();
}
if (mItems == null) return;
mAnimator = ValueAnimator.ofFloat(0, mItemHeight * mItems.size());
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setHeight(Math.round((float) animation.getAnimatedValue()));
}
});
mAnimator.setDuration(500);
mAnimator.start();
}
}
示例2: endAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
super.endAnimation(dynamicWeatherView, listener);
ValueAnimator animator1 = ValueAnimator.ofFloat(1, 0);
animator1.setInterpolator(new AccelerateInterpolator());
animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
speed = (float) animation.getAnimatedValue() * 32;
rotate = (float) animation.getAnimatedValue();
}
});
AnimatorSet animSet = new AnimatorSet();
animSet.play(animator1);
animSet.setDuration(1000);
if (listener != null) {
animSet.addListener(listener);
}
animSet.start();
}
示例3: createAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
long[] delays=new long[]{500,250,0,250,500};
for (int i = 0; i < 5; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);
scaleAnim.setDuration(900);
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;
}
示例4: 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;
}
示例5: onLayoutChange
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (mSheetAnimator != null) mSheetAnimator.cancel();
mRequestView.removeOnLayoutChangeListener(this);
mContainerHeightDifference = (bottom - top) - (oldBottom - oldTop);
ValueAnimator containerAnimator = ValueAnimator.ofFloat(1f, 0f);
containerAnimator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float alpha = (Float) animation.getAnimatedValue();
update(alpha);
}
});
mSheetAnimator = containerAnimator;
mSheetAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS);
mSheetAnimator.setInterpolator(new LinearOutSlowInInterpolator());
mSheetAnimator.addListener(this);
mSheetAnimator.start();
}
示例6: 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();
}
}
示例7: createAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public List<Animator> createAnimation() {
List<Animator> animators=new ArrayList<>();
float circleSpacing=4;
float radius=(getWidth()-circleSpacing*2)/6;
int[] delays=new int[]{70,140,210};
for (int i = 0; i < 3; i++) {
final int index=i;
ValueAnimator scaleAnim=ValueAnimator.ofFloat(getHeight()/2,getHeight()/2-radius*2,getHeight()/2);
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();
}
});
scaleAnim.start();
animators.add(scaleAnim);
}
return animators;
}
示例8: 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();
}
示例9: init
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void init() {
// init animator
mValueAnimator = ValueAnimator.ofFloat(0, mProgressValue);
mValueAnimator.setDuration(DEFAULT_ANIMATION_TIME);
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mProgressValue = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
super.setScaleType(SCALE_TYPE);
mReady = true;
if (mSetupPending) {
setup();
mSetupPending = false;
}
}
示例10: doExitAnim
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void doExitAnim(final View contentView, long animDuration) {
if (builder.gravity == Gravity.BOTTOM) {
ValueAnimator exitAnimator = ValueAnimator.ofFloat(0, contentView.getHeight());
exitAnimator.setDuration(animDuration);
exitAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
contentView.setTranslationY(value);
}
});
exitAnimator.start();
} else {
ScaleAnimation scaleAnimation = new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F,
Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
scaleAnimation.setDuration(animDuration);
scaleAnimation.setFillAfter(true);
contentView.startAnimation(scaleAnimation);
}
}
示例11: getResetYAnimator
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 垂直方向的重置动画
*
* @return
*/
private ValueAnimator getResetYAnimator() {
if (resetYAnimator != null) {
resetYAnimator.removeAllUpdateListeners();
} else {
resetYAnimator = ValueAnimator.ofFloat();
}
resetYAnimator.setDuration(150);
resetYAnimator.setInterpolator(mAccInterpolator);
resetYAnimator.setEvaluator(mFloatEvaluator);
return resetYAnimator;
}
示例12: getTranslateXAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private ValueAnimator getTranslateXAnimation() {
final ValueAnimator animator = ValueAnimator.ofFloat(mTranslateX, 0);
animator.setDuration(animationDuration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mTranslateX = (float) valueAnimator.getAnimatedValue();
}
});
return animator;
}
示例13: initAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 进度移动动画 通过插值的方式改变移动的距离
*/
private void initAnimation() {
progressAnimator = ValueAnimator.ofFloat(0, mProgress);
progressAnimator.setDuration(duration);
progressAnimator.setStartDelay(startDelay);
progressAnimator.setInterpolator(new LinearInterpolator());
progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = (float) valueAnimator.getAnimatedValue();
//进度数值只显示整数,我们自己的需求,可以忽略
textString = formatNum(format2Int(value));
//把当前百分比进度转化成view宽度对应的比例
currentProgress = value * mWidth / 100;
//进度回调方法
if (progressListener != null) {
progressListener.currentProgressListener(value);
}
//移动百分比提示框,只有当前进度到提示框中间位置之后开始移动,
//当进度框移动到最右边的时候停止移动,但是进度条还可以继续移动
//moveDis是tip框移动的距离
if (currentProgress >= (tipWidth / 2) &&
currentProgress <= (mWidth - tipWidth / 2)) {
moveDis = currentProgress - tipWidth / 2;
}
invalidate();
}
});
progressAnimator.start();
/* int ssss=mWidth;
currentProgress = mProgress / 100 * mWidth; //这个是进行显示的进度 60%
invalidate();*/
}
示例14: startSuccessSymbolAnim
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 开始加载成功动画
*/
private void startSuccessSymbolAnim() {
currentPath.reset();
pathMeasure.setPath(successSymbolPath, false);
pathMeasure.getPosTan(0, mCurrentPosition, null);
currentPath.moveTo(mCurrentPosition[0], mCurrentPosition[1]);
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, pathMeasure.getLength());
valueAnimator.setDuration(500);
// 减速插值器
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (isLoading)
return;
float value = (Float) animation.getAnimatedValue();
// 获取当前点坐标封装到mCurrentPosition
float[] tmp = mCurrentPosition;
pathMeasure.getPosTan(value, mCurrentPosition, null);
currentPath.quadTo(tmp[0], tmp[1], mCurrentPosition[0], mCurrentPosition[1]);
invalidateCallback.redraw();
}
});
valueAnimator.start();
}
示例15: upAndCancelEvent
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void upAndCancelEvent() {
if (isInCircle && mDistanceCircles == 0) {
reset();
if (mOnPointDragListener != null) {
mOnPointDragListener.onRecovery(this);
}
} else if (!mIsDragOut) {
mCenterCircleCopy.set(mCenterCircle.x, mCenterCircle.y);
mDragCircleCopy.set(mDragCircle.x, mDragCircle.y);
if (mRecoveryAnim == null) {
mRecoveryAnim = ValueAnimator.ofFloat(1.f, -Math.abs(mRecoveryAnimBounce));
mRecoveryAnim.setDuration(mRecoveryAnimDuration);
mRecoveryAnim.addUpdateListener(this);
mRecoveryAnim.addListener(this);
}
if (mRecoveryAnimInterpolator != null)
mRecoveryAnim.setInterpolator(mRecoveryAnimInterpolator);
mRecoveryAnim.start();
} else {
if (mDistanceCircles <= mMaxRadiusTrebling) {
reset();
if (mOnPointDragListener != null) {
mOnPointDragListener.onRecovery(this);
}
} else if (!TextUtils.isEmpty(clearSign)) {
ClearViewHelper.getInstance().clearPointViewBySign(origView, clearSign);
} else {
startRemove();
}
}
}