android.animation.ValueAnimator Java Examples
The following examples show how to use
android.animation.ValueAnimator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonTabLayout.java From FlycoTabLayout with MIT License | 6 votes |
@Override public void onAnimationUpdate(ValueAnimator animation) { View currentTabView = mTabsContainer.getChildAt(this.mCurrentTab); IndicatorPoint p = (IndicatorPoint) animation.getAnimatedValue(); mIndicatorRect.left = (int) p.left; mIndicatorRect.right = (int) p.right; if (mIndicatorWidth < 0) { //indicatorWidth小于0时,原jpardogo's PagerSlidingTabStrip } else {//indicatorWidth大于0时,圆角矩形以及三角形 float indicatorLeft = p.left + (currentTabView.getWidth() - mIndicatorWidth) / 2; mIndicatorRect.left = (int) indicatorLeft; mIndicatorRect.right = (int) (mIndicatorRect.left + mIndicatorWidth); } invalidate(); }
Example #2
Source File: DragState.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private ValueAnimator createCancelAnimationLocked() { final ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder( PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_X, mCurrentX - mThumbOffsetX, mCurrentX), PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_Y, mCurrentY - mThumbOffsetY, mCurrentY), PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_SCALE, 1, 0), PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_ALPHA, mOriginalAlpha, 0)); final AnimationListener listener = new AnimationListener(); animator.setDuration(MIN_ANIMATION_DURATION_MS); animator.setInterpolator(mCubicEaseOutInterpolator); animator.addListener(listener); animator.addUpdateListener(listener); mService.mAnimationHandler.post(() -> animator.start()); return animator; }
Example #3
Source File: Case3Scene.java From scene with Apache License 2.0 | 6 votes |
@NonNull @Override protected Animator onPopAnimator(final AnimationInfo fromInfo, final AnimationInfo toInfo) { final View toView = toInfo.mSceneView; final View fromView = fromInfo.mSceneView; ValueAnimator fromAlphaAnimator = ObjectAnimator.ofFloat(fromView, View.ALPHA, 1.0f, 0.0f); fromAlphaAnimator.setInterpolator(new LinearInterpolator()); fromAlphaAnimator.setDuration(150 * 20); fromAlphaAnimator.setStartDelay(50 * 20); ValueAnimator fromTranslateAnimator = ObjectAnimator.ofFloat(fromView, View.TRANSLATION_Y, 0, 0.08f * toView.getHeight()); fromTranslateAnimator.setInterpolator(new AccelerateInterpolator(2)); fromTranslateAnimator.setDuration(200 * 20); ValueAnimator toAlphaAnimator = ObjectAnimator.ofFloat(toView, View.ALPHA, 0.7f, 1.0f); toAlphaAnimator.setInterpolator(new LinearOutSlowInInterpolator()); toAlphaAnimator.setDuration(20 * 20); return TransitionUtils.mergeAnimators(fromAlphaAnimator, fromTranslateAnimator, toAlphaAnimator); }
Example #4
Source File: PreciseLocationActivity.java From VirtualLocation with Apache License 2.0 | 6 votes |
/** * 使组件变回原有形状 * @param view */ private void repaintView(final View view){ AnimatorSet set = new AnimatorSet(); ValueAnimator animator = ValueAnimator.ofFloat(width, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mBeginLocation .getLayoutParams(); params.leftMargin = (int) value; params.rightMargin = (int) value; view.setLayoutParams(params); } }); ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "scaleX", 0.5f, 1f); set.setDuration(1000); set.setInterpolator(new AccelerateDecelerateInterpolator()); set.playTogether(animator, animator2); set.start(); }
Example #5
Source File: PropertyAnimActivity.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
public void testObjectAnimator(View v) { if (v.getId() == R.id.sdi_objectanimator_btn) { // 简单示例:View的横向移动 ObjectAnimator.ofFloat(mAnimView, "translationX", 0.0f, -200.0f) .setDuration(C.Int.ANIM_DURATION * 2) .start(); } else { // 复合示例:View弹性落下然后弹起,执行一次 ObjectAnimator yBouncer = ObjectAnimator.ofFloat(mAnimView, "y", mAnimView.getY(), 400.0f); yBouncer.setDuration(C.Int.ANIM_DURATION * 2); // 设置插值器(用于调节动画执行过程的速度) yBouncer.setInterpolator(new BounceInterpolator()); // 设置重复次数(缺省为0,表示不重复执行) yBouncer.setRepeatCount(1); // 设置重复模式(RESTART或REVERSE),重复次数大于0或INFINITE生效 yBouncer.setRepeatMode(ValueAnimator.REVERSE); // 设置动画开始的延时时间(200ms) yBouncer.setStartDelay(200); yBouncer.start(); } }
Example #6
Source File: PreferenceCard.java From narrate-android with Apache License 2.0 | 6 votes |
protected void animateClosed() { mExpanded = false; int toHeight = gap * 2; toHeight += getChildAt(0).getHeight(); ValueAnimator anim = ValueAnimator.ofInt(getHeight(), toHeight); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { getLayoutParams().height = (int) animation.getAnimatedValue(); requestLayout(); } }); anim.setInterpolator(new DecelerateInterpolator()); anim.start(); }
Example #7
Source File: SLTouchListener.java From SphereLayout with MIT License | 6 votes |
public SLTouchListener(SphereLayout sphereLayout) { mSphereLayout = sphereLayout; mTouchSlop = ViewConfiguration.get(mSphereLayout.getContext()).getScaledTouchSlop(); mInterpolator = new SpringInterpolator(); mState = new RotateState(); mRotateAnimator = new ValueAnimator(); mRotateAnimator.setInterpolator(mInterpolator); mRotateAnimator.setIntValues(MAX_ROTATE_DEGREE, 0); mRotateAnimator.setDuration(DURATION); mRotateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mState.rotateDegree = (Integer) animation.getAnimatedValue(); mSphereLayout.rotate(mState.direction, mState.rotateDegree); } }); mFixAnimator = new ValueAnimator(); mFixAnimator.setInterpolator(new DecelerateInterpolator()); }
Example #8
Source File: SwipeHelper.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
private void snapChild(final View animView, final float targetLeft, float velocity) { final boolean canBeDismissed = mCallback.canChildBeDismissed(animView); AnimatorUpdateListener updateListener = new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed); } }; Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener); if (anim == null) { return; } int duration = SNAP_ANIM_LEN; anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { mSnappingChild = false; updateSwipeProgressFromOffset(animView, canBeDismissed); mCallback.onChildSnappedBack(animView, targetLeft); } }); prepareSnapBackAnimation(animView, anim); mSnappingChild = true; anim.start(); }
Example #9
Source File: CircularRevealActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void revealImageCircular() { int x = getX(); int y = getY(); int radius = getRadius(); ValueAnimator anim = ViewAnimationUtils.createCircularReveal(mImageView, x, y, 0, radius); anim.setDuration( 1000 ); anim.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mImageView.setVisibility( View.VISIBLE ); } }); anim.start(); }
Example #10
Source File: RollSquareView.java From RollSquareView with Apache License 2.0 | 6 votes |
private ValueAnimator createRollValueAnimator() { ValueAnimator rollAnim = ValueAnimator.ofFloat(0, 90).setDuration(mSpeed); // rollAnim.setInterpolator(mRollInterpolator); rollAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Object animatedValue = animation.getAnimatedValue(); mRotateDegree = (float) animatedValue; if (!isHardwareAccelerated()) { invalidate(mDirtyRect); } else { invalidate(); } } }); return rollAnim; }
Example #11
Source File: BaseChart.java From OXChart with Apache License 2.0 | 6 votes |
protected void startAnimation(Canvas canvas) { if(anim!=null){ anim.cancel(); } LogUtil.w(TAG, "开始绘制动画"); anim = initAnim(); if(anim==null){ drawChart(canvas); }else{ anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.addUpdateListener((ValueAnimator animation)->{ evaluatorData(animation); invalidate(); }); anim.setDuration(animDuration); anim.start(); } }
Example #12
Source File: DownloadProgressBar.java From UltimateAndroid with Apache License 2.0 | 6 votes |
private void setCurrentPlayTimeByStateAndPlay(long[] tab, State mState) { switch (mState) { case ANIMATING_LINE_TO_DOT: mArrowToLineAnimatorSet.start(); for (int i = 0; i < mArrowToLineAnimatorSet.getChildAnimations().size(); i++) { ((ValueAnimator) mArrowToLineAnimatorSet.getChildAnimations().get(i)).setCurrentPlayTime(tab[i]); } break; case ANIMATING_PROGRESS: mProgressAnimationSet.start(); for (int i = 0; i < mProgressAnimationSet.getChildAnimations().size(); i++) { ((ValueAnimator) mProgressAnimationSet.getChildAnimations().get(i)).setCurrentPlayTime(tab[i]); } break; case ANIMATING_ERROR: mErrorAnimation.start(); mErrorAnimation.setCurrentPlayTime(tab[0]); break; case ANIMATING_SUCCESS: mSuccessAnimation.start(); mSuccessAnimation.setCurrentPlayTime(tab[0]); break; } }
Example #13
Source File: BottomNavigationTab.java From BottomNavigation with Apache License 2.0 | 6 votes |
public void unSelect(boolean setActiveColor, int animationDuration) { isActive = false; ValueAnimator animator = ValueAnimator.ofInt(containerView.getPaddingTop(), paddingTopInActive); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { containerView.setPadding(containerView.getPaddingLeft(), (Integer) valueAnimator.getAnimatedValue(), containerView.getPaddingRight(), containerView.getPaddingBottom()); } }); animator.setDuration(animationDuration); animator.start(); labelView.setTextColor(mInActiveColor); iconView.setSelected(false); if (badgeItem != null) { badgeItem.unSelect(); } }
Example #14
Source File: MaterialWaveView.java From SprintNBA with Apache License 2.0 | 6 votes |
@Override public void onRefreshing(MaterialRefreshLayout br) { setHeadHeight((int) (Util.dip2px(getContext(), DefaulHeadHeight))); ValueAnimator animator = ValueAnimator.ofInt(getWaveHeight(),0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //Log.i("anim", "value--->" + (int) animation.getAnimatedValue()); setWaveHeight((int) animation.getAnimatedValue()); invalidate(); } }); animator.setInterpolator(new BounceInterpolator()); animator.setDuration(200); animator.start(); }
Example #15
Source File: PointView.java From AndroidDemo with Apache License 2.0 | 6 votes |
private void startAnimation() { Point startPoint = new Point(RADIUS, RADIUS); Point endPoint = new Point(getWidth() - RADIUS, getHeight() - RADIUS); ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), startPoint, endPoint); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { currentPoint = (Point) animation.getAnimatedValue(); invalidate(); } }); ObjectAnimator anim2 = ObjectAnimator.ofObject(this, "color", new ColorEvaluator(), "#00FFFF", "#FF1100"); AnimatorSet animSet = new AnimatorSet(); animSet.play(anim).with(anim2); animSet.setDuration(5000); animSet.start(); }
Example #16
Source File: DragView.java From LaunchEnr with GNU General Public License v3.0 | 6 votes |
private void animateFilterTo(float[] targetFilter) { float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter; mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length); if (mFilterAnimator != null) { mFilterAnimator.cancel(); } mFilterAnimator = ValueAnimator.ofObject(new FloatArrayEvaluator(mCurrentFilter), oldFilter, targetFilter); mFilterAnimator.setDuration(COLOR_CHANGE_DURATION); mFilterAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter)); invalidate(); } }); mFilterAnimator.start(); }
Example #17
Source File: Chronos.java From crystal-preloaders with Apache License 2.0 | 6 votes |
@Override protected List<ValueAnimator> setupAnimation() { valueAnimator = ValueAnimator.ofInt(0, 360); valueAnimator.setDuration(7000); valueAnimator.setRepeatCount(ValueAnimator.INFINITE); valueAnimator.setRepeatMode(ValueAnimator.RESTART); valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { degree = (int) animation.getAnimatedValue(); getTarget().invalidate(); } }); // create animator list final List<ValueAnimator> animators = new ArrayList<>(); animators.add(valueAnimator); return animators; }
Example #18
Source File: SmartLoadingView.java From SmartLoadingView with MIT License | 6 votes |
/** * 绘制对勾的动画 */ private void set_draw_ok_animation() { animator_draw_ok = ValueAnimator.ofFloat(1, 0); animator_draw_ok.setDuration(duration); animator_draw_ok.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { startDrawOk = true; isDrawLoading = false; float value = (Float) animation.getAnimatedValue(); effect = new DashPathEffect(new float[]{pathMeasure.getLength(), pathMeasure.getLength()}, value * pathMeasure.getLength()); okPaint.setPathEffect(effect); invalidate(); } }); }
Example #19
Source File: ActionAnimatorSet.java From ActionAnimatorSet with GNU General Public License v3.0 | 6 votes |
private void addObservable() { //如果是With和After的,则设置AnimatorListener监听,With和After共用一个监听 //如果是Between的,则设置UpdateListener监听 for (int i = 0; i < mAllNodes.size(); ++i) { AnimNode node = mAllNodes.get(i); if (node.withAbservable != null && node.withAbservable.size() > 0) node.mAnim.addListener(new WithAndAfterListener(node)); if (node.afterAbservable != null && node.afterAbservable.size() > 0) if (node.mAnim.getListeners() == null || node.mAnim.getListeners().size() == 0) node.mAnim.addListener(new WithAndAfterListener(node)); if (node.betweenAbservable != null && node.betweenAbservable.size() > 0) if (node.mAnim instanceof ValueAnimator) ((ValueAnimator) node.mAnim).addUpdateListener(new BetweenListener(node)); } }
Example #20
Source File: CreateCardView.java From Slide with GNU General Public License v3.0 | 6 votes |
private static ValueAnimator slideAnimator(int start, int end, final View v) { ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { //Update Height int value = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = v.getLayoutParams(); layoutParams.height = value; v.setLayoutParams(layoutParams); } }); return animator; }
Example #21
Source File: BouncingSlidingDotView.java From widgetlab with Apache License 2.0 | 6 votes |
@NonNull private AnimatorSet getMoveAnimator(long ratioAnimationTotalDuration) { AnimatorSet moveAnimatorSet = new AnimatorSet(); ValueAnimator slidingAnimator = ValueAnimator.ofInt(startLeft, 0); slidingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { targetLeft = (int) animator.getAnimatedValue(); invalidate(); } }); slidingAnimator.setInterpolator(new LinearInterpolator()); slidingAnimator.setDuration(ratioAnimationTotalDuration); AnimatorSet bounceSet = getBounceAnimatorSet(ratioAnimationTotalDuration); moveAnimatorSet.playTogether(slidingAnimator, bounceSet); return moveAnimatorSet; }
Example #22
Source File: RLetterS.java From ReadMark with Apache License 2.0 | 6 votes |
@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(); }
Example #23
Source File: DLetter.java From CoolAndroidAnim with Apache License 2.0 | 6 votes |
@Override public void startAnim() { mAnimator = ValueAnimator.ofFloat(0, 1).setDuration(mDuration); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float factor = (float) animation.getAnimatedValue(); //竖线 mSecPoint.y = (int) (mFirPoint.y - mLineLength * factor); if (factor > 0.333f) { //2/3处开始画圆 float zoroToOne = (factor - 0.333f) * 3 / 2; mSweepAngle = -(int) (360 * zoroToOne); } } }); mAnimator.start(); }
Example #24
Source File: AnimatedCircleDrawable.java From Camera2 with Apache License 2.0 | 6 votes |
public void animateToFullSize() { final ValueAnimator animator = ValueAnimator.ofInt(getLevel(), DRAWABLE_MAX_LEVEL); animator.setDuration(CIRCLE_ANIM_DURATION_MS); animator.setInterpolator(Gusterpolator.INSTANCE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { setLevel((Integer) animation.getAnimatedValue()); } }); animator.start(); }
Example #25
Source File: RefreshAnimeUtil.java From RefreshLayout with Apache License 2.0 | 6 votes |
public static void startScaleAnime(final View view, float newScale, Animator.AnimatorListener listener) { ValueAnimator anime = ValueAnimator.ofFloat(view.getScaleX(), newScale); anime.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float s = Float.parseFloat(animation.getAnimatedValue().toString()); view.setScaleX(s); view.setScaleY(s); } }); if (listener != null) { anime.addListener(listener); } anime.setDuration(mAnimeDuration); anime.start(); }
Example #26
Source File: FloatViewManager.java From RelaxFinger with GNU General Public License v2.0 | 5 votes |
private void moveBallToRight() { final WindowManager.LayoutParams ballLayoutParams = mBallView.getWindowLayoutParams(); ValueAnimator mSlideToBoundaryAnim = ValueAnimator.ofFloat(ballLayoutParams.x, FloatingBallUtils.getScreenWidth() - ballLayoutParams.width); int maxDuration = 200; int duration = (int) (ballLayoutParams.x * maxDuration / (FloatingBallUtils .getScreenWidth() / 2 - ballLayoutParams.width / 2)); if(duration < 0) duration = 0; mSlideToBoundaryAnim.setDuration(duration); mSlideToBoundaryAnim.setInterpolator(new DecelerateInterpolator()); mSlideToBoundaryAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float currentValue = (Float) valueAnimator.getAnimatedValue(); ballLayoutParams.x = (int) currentValue; updateBallPos(); } }); mSlideToBoundaryAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { doIfSavePosition(); calculateMenuPos(); mIsMoving = false; } }); mSlideToBoundaryAnim.start(); mIsMoving = true; }
Example #27
Source File: SpecialEffectsSeekBar.java From TikTok with Apache License 2.0 | 5 votes |
private void unTouchThumbAnimator(){ ValueAnimator valueAnimator = ValueAnimator.ofFloat(1f,0f); valueAnimator.setDuration(300); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mTidalPatAdjustThumbWidth = DensityUtils.dp2px(10) + (float) animation.getAnimatedValue() * mTouchChangeBigWidth; mTidalPatAdjustThumbHeight = DensityUtils.dp2px(24) + (float) animation.getAnimatedValue() * mTouchChangeBigHeight; invalidate(); } }); valueAnimator.start(); }
Example #28
Source File: PlayerFragment.java From android-material-motion with Apache License 2.0 | 5 votes |
private void runButtonAnimation() { next.setScaleX(0); next.setScaleY(0); prev.setScaleX(0); prev.setScaleY(0); Path arcPath = createArcPath(playPause, 0, 0, -playPause.getTranslationY()); ValueAnimator pathAnimator = ValueAnimator.ofFloat(0, 1); pathAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { private float point[] = new float[2]; private PathMeasure pathMeasure = new PathMeasure(arcPath, false); @Override public void onAnimationUpdate(ValueAnimator animation) { final float value = animation.getAnimatedFraction(); // Gets the point at the fractional path length pathMeasure.getPosTan(pathMeasure.getLength() * value, point, null); // Sets view location to the above point playPause.setTranslationX(point[0]); playPause.setTranslationY(point[1]); } }); pathAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); pathAnimator.setDuration(duration(R.integer.path_duration) / 2); pathAnimator.start(); next.animate() .setDuration(duration(R.integer.scale_duration)) .setStartDelay(duration(R.integer.short_delay)) .scaleX(1).scaleY(1) .start(); prev.animate() .setDuration(duration(R.integer.scale_duration)) .setStartDelay(duration(R.integer.short_delay)) .scaleX(1).scaleY(1) .start(); }
Example #29
Source File: BeaconLineChart.java From BLE-Indoor-Positioning with Apache License 2.0 | 5 votes |
protected ValueAnimator startValueAnimator(ValueAnimator valueAnimator, float targetValue) { float originValue = targetValue; if (valueAnimator != null) { valueAnimator.cancel(); originValue = (float) valueAnimator.getAnimatedValue(); } valueAnimator = ValueAnimator.ofFloat(originValue, targetValue); valueAnimator.setDuration(200); valueAnimator.start(); return valueAnimator; }
Example #30
Source File: AudioBookPlayActivity.java From HaoReader with GNU General Public License v3.0 | 5 votes |
private void startRotationAnim() { if (animator == null) { animator = ValueAnimator.ofFloat(0f, 360f); animator.addUpdateListener(animation -> ivCover.setRotation((Float) animation.getAnimatedValue())); animator.setDuration(30000); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setStartDelay(1000); animator.start(); } else { animator.resume(); } }