本文整理汇总了Java中android.animation.ValueAnimator.ofInt方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.ofInt方法的具体用法?Java ValueAnimator.ofInt怎么用?Java ValueAnimator.ofInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.ofInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override public void setUpAnimation() {
for (int i = 0; i < circlesSize; 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) {
circles[index].setAlpha((int)animation.getAnimatedValue());
if (invalidateListener != null) {
invalidateListener.reDraw();
}
}
});
fadeAnimator.start();
}
}
示例2: start
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void start() {
if (mAnimator == null) {
mAnimator = ValueAnimator.ofInt(0, 360);
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
startAngle = (int) animation.getAnimatedValue();
postInvalidate();
}
});
mAnimator.setDuration(1000);
mAnimator.setRepeatCount(ValueAnimator.INFINITE);
mAnimator.setRepeatMode(ValueAnimator.RESTART);
}
if (!mAnimator.isStarted()) {
mAnimator.start();
}
}
示例3: animToProgress
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 动画的方式执行动画
*/
private void animToProgress(int startP, int endP) {
if (animator == null) {
} else {
animator.cancel();
}
animator = ValueAnimator.ofInt(startP, endP);
animator.setDuration(200);
animator.setInterpolator(new DecelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
mProgress = (int) valueAnimator.getAnimatedValue();
postInvalidateOnAnimation();
}
});
animator.start();
}
示例4: initView
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void initView() {
mPath = new Paint();
mPantR = new Paint();
mPath.setAntiAlias(true);
mPantR.setAntiAlias(true);
mPath.setColor(Color.WHITE);
mPantR.setColor(0x55000000);
DensityUtil density = new DensityUtil();
mRadius = density.dip2px(20);
mOutsideCircle = density.dip2px(7);
mPath.setStrokeWidth(density.dip2px(3));
mPantR.setStrokeWidth(density.dip2px(3));
mAnimator = ValueAnimator.ofInt(0,360);
mAnimator.setDuration(720);
mAnimator.addUpdateListener(animation -> {
endAngle = (int) animation.getAnimatedValue();
postInvalidate();
});
mAnimator.setRepeatCount(ValueAnimator.INFINITE);
mAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
}
示例5: onScrollStateChanged
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (mAppBarLayout == null || newState != 0 || mAppBarLayoutDistance == 0
|| (mAppBarLayoutDistance == mAppBarLayout.getHeight() && mScrollDistance != 0)) {
return;
}
boolean show = mAppBarLayoutDistance < mAppBarLayout.getHeight() * 0.5f
|| mScrollDistance <= mViewPagerParent.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(mAppBarLayoutDistance, show ? 0 : mAppBarLayout.getHeight());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mAppBarLayoutDistance = (int) animation.getAnimatedValue();
mAppBarLayout.setTranslationY(-mAppBarLayoutDistance);
}
});
animator.start();
}
示例6: startAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 开启动画
*
* @param point 单位点
* @param duration 持续时长
*/
private void startAnimation(final Point point, long duration) {
ValueAnimator valueAnimator;
// 1.判断是否有按下状态的图片的资源ID,采用不同策略的属性动画
if (mPressImageId == 0) {
// 2.判断动画缩放模式,采用不同策略的属性动画
if (mAnimationScaleMode == 1) {
valueAnimator = ValueAnimator.ofInt(point.radius, (int) (mAnimationScaleRate * point.radius), point.radius);
} else {
valueAnimator = ValueAnimator.ofInt((int) (mAnimationScaleRate * point.radius), point.radius);
}
} else {
valueAnimator = ValueAnimator.ofInt(0, point.radius);
}
valueAnimator.setDuration(duration);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
point.radius = (int) animation.getAnimatedValue();
postInvalidate();
}
});
valueAnimator.start();
// 3.添加ValueAnimator至动画列表
mPointAnimators.add(valueAnimator);
}
示例7: setProgressWidthAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void setProgressWidthAnimation(@IntRange(from = 0, to = 100) int progress) {
if (progress > 100) {
progress = 100;
}
if (progress < 0) {
progress = 0;
}
if (animator != null && animator.isRunning()) {
animator.cancel();
animator = null;
}
animator = ValueAnimator.ofInt(mProgress, progress);
int duration = 15 * Math.abs(progress - mProgress);
animator.setDuration(duration);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
int value = (int) valueAnimator.getAnimatedValue();
if (mProgress != value) {
mProgress = value;
if (mListener != null) {
mListener.onProgressChanged(GradeProgressView.this, mProgress);
}
postInvalidate();
}
}
});
animator.start();
}
示例8: smoothScrollTo
import android.animation.ValueAnimator; //导入方法依赖的package包/类
private void smoothScrollTo(int destHeight) {
ValueAnimator animator = ValueAnimator.ofInt(getVisiableHeight(), destHeight);
animator.setDuration(300).start();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setVisiableHeight((int) animation.getAnimatedValue());
}
});
animator.start();
}
示例9: smoothScrollTo
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 这是一个让布局高度改变的方法
*/
public void smoothScrollTo(int Height) {
ValueAnimator animator = ValueAnimator.ofInt(getVisibleHeight(), Height);
animator.setDuration(300).start();
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
setVisibleHeight((int) animation.getAnimatedValue());
}
});
animator.start();
}
示例10: animSpinner
import android.animation.ValueAnimator; //导入方法依赖的package包/类
protected ValueAnimator animSpinner(int endValue, Interpolator interpolator) {
if (mSpinner != endValue) {
if (reboundAnimator != null) {
reboundAnimator.cancel();
}
reboundAnimator = ValueAnimator.ofInt(mSpinner, endValue);
reboundAnimator.setDuration(mReboundDuration);
reboundAnimator.setInterpolator(interpolator);
reboundAnimator.addUpdateListener(reboundUpdateListener);
reboundAnimator.addListener(reboundAnimatorEndListener);
reboundAnimator.start();
}
return reboundAnimator;
}
示例11: start
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void start() {
if (mAnimator == null) {
mAnimator = ValueAnimator.ofInt(0, LINE_COUNT - 1);
mAnimator.addUpdateListener(mUpdateListener);
mAnimator.setDuration(600);
mAnimator.setRepeatMode(ValueAnimator.RESTART);
mAnimator.setRepeatCount(ValueAnimator.INFINITE);
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.start();
} else if (!mAnimator.isStarted()) {
mAnimator.start();
}
}
示例12: startHideAnimation
import android.animation.ValueAnimator; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startHideAnimation() {
//Start the Handler to clean up the Alert
if (!enableInfiniteDuration) {
runningAnimation = new Runnable() {
@Override
public void run() {
hide();
}
};
postDelayed(runningAnimation, duration);
}
if (enableProgress && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
pbProgress.setVisibility(View.VISIBLE);
final ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 100);
valueAnimator.setDuration(getDuration());
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(final ValueAnimator animation) {
getProgressBar().setProgress((int) animation.getAnimatedValue());
}
});
valueAnimator.start();
}
}
示例13: hiddenRefreshHeaderView
import android.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 隐藏下拉刷新控件,带动画
*/
private void hiddenRefreshHeaderView() {
ValueAnimator animator = ValueAnimator.ofInt(mWholeHeaderView.getPaddingTop(), mMinWholeHeaderViewPaddingTop);
animator.setDuration(mRefreshViewHolder.getTopAnimDuration());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
int paddingTop = (int) animation.getAnimatedValue();
mWholeHeaderView.setPadding(0, paddingTop, 0, 0);
}
});
animator.start();
}
示例14: animLayoutByTime
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void animLayoutByTime(int start, int end, AnimatorUpdateListener listener, AnimatorListener animatorListener) {
ValueAnimator va = ValueAnimator.ofInt(start, end);
va.setInterpolator(new DecelerateInterpolator());
va.addUpdateListener(listener);
va.addListener(animatorListener);
va.setDuration((int) (Math.abs(start - end) * animFraction));
va.start();
// offerToQueue(va);
}
示例15: setCurrentData
import android.animation.ValueAnimator; //导入方法依赖的package包/类
public void setCurrentData(int data){
ValueAnimator animator=ValueAnimator.ofInt(0,data);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
currentValue = (int) animation.getAnimatedValue();
invalidate();
}
});
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(2500);
animator.start();
}