當前位置: 首頁>>代碼示例>>Java>>正文


Java ValueAnimator.addUpdateListener方法代碼示例

本文整理匯總了Java中android.animation.ValueAnimator.addUpdateListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ValueAnimator.addUpdateListener方法的具體用法?Java ValueAnimator.addUpdateListener怎麽用?Java ValueAnimator.addUpdateListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.animation.ValueAnimator的用法示例。


在下文中一共展示了ValueAnimator.addUpdateListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startAlphaAnim

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public static void startAlphaAnim(@NonNull final View view, int duration, @Nullable Animator.AnimatorListener listener, float... values) {
    ValueAnimator alphaAnim = ObjectAnimator.ofFloat(values);
    alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float alpha = (float) animation.getAnimatedValue();
            view.setAlpha(alpha);
        }
    });
    if (listener != null) {
        alphaAnim.addListener(listener);
    }

    alphaAnim.setDuration(duration);
    alphaAnim.start();
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:17,代碼來源:AnimationUtils.java

示例2: endAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
    super.endAnimation(dynamicWeatherView, listener);
    ValueAnimator animator = ValueAnimator.ofFloat(1, -1);
    animator.setDuration(1000);
    animator.setRepeatCount(0);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            hillTransFactor = (float) animation.getAnimatedValue();
        }
    });
    if (listener != null) {
        animator.addListener(listener);
    }
    animator.start();
}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:19,代碼來源:OvercastType.java

示例3: 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;
}
 
開發者ID:hiwhitley,項目名稱:DownloadProgressButton,代碼行數:21,代碼來源:DownloadProgressButton.java

示例4: releaseView

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public void releaseView() {
    if (mAnimator==null){
        final ValueAnimator valAnimator=ValueAnimator.ofFloat(mPercent,0f);
        valAnimator.setDuration(500);
        valAnimator.setInterpolator(new OvershootInterpolator());
        valAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {

               float animValue= (float) valAnimator.getAnimatedValue();
                setPercent(animValue);

            }
        });
        this.mAnimator=valAnimator;
    }else {
        mAnimator.cancel();
        mAnimator.setFloatValues(mPercent,0f);
    }
    mAnimator.start();
}
 
開發者ID:RuanXiaoHui,項目名稱:PlainFly,代碼行數:22,代碼來源:SkyLayout.java

示例5: getAnimators

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override
public List<Animator> getAnimators() {
    final List<Animator> animations = new ArrayList<>();
    calculate();
    if (mCameraDistance != null) {
        final ValueAnimator animator = ValueAnimator.ofFloat(mCurrentCameraDistance, mCameraDistance);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                viewToMove.setCameraDistance((float) valueAnimator.getAnimatedValue());
            }
        });
        animations.add(animator);
    }
    return animations;
}
 
開發者ID:GcsSloop,項目名稱:diycode,代碼行數:17,代碼來源:ExpectAnimCameraDistanceManager.java

示例6: createMoveValueAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * 關注3:設置旋轉動畫
 */
private ValueAnimator createMoveValueAnimator() {

    // 通過屬性動畫進行設置
    ValueAnimator moveAnim = ValueAnimator.ofFloat(0, 90).setDuration(moveSpeed);

    moveAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Object animatedValue = animation.getAnimatedValue();

            // 賦值
            mRotateDegree = (float) animatedValue;

            // 更新視圖
            invalidate();
        }
    });
    return moveAnim;
}
 
開發者ID:Carson-Ho,項目名稱:Kawaii_LoadingView,代碼行數:23,代碼來源:Kawaii_LoadingView.java

示例7: setUpAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@Override public void setUpAnimation() {
  for (int i = 0; i < numberOfLine; 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) {
        lines[index].setAlpha((int)animation.getAnimatedValue());
        if (invalidateListener != null) {
          invalidateListener.reDraw();
        }
      }
    });

    fadeAnimator.start();
  }
}
 
開發者ID:nntuyen,項目名稱:mkloader,代碼行數:21,代碼來源:LineSpinner.java

示例8: 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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:ElectricFanLoadingRenderer.java

示例9: createAnimation

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public List<Animator> createAnimation() {
    List<Animator> 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]);

        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();

            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:26,代碼來源:ProgressIndicatorView.java

示例10: colorAnimateImageView

import android.animation.ValueAnimator; //導入方法依賴的package包/類
private void colorAnimateImageView() {
    final int activatedColor = context.getResources().getColor(R.color.like_icon_activated);

    final ValueAnimator colorAnim = !isLiked ? ObjectAnimator.ofFloat(0f, 1f)
            : ObjectAnimator.ofFloat(1f, 0f);
    colorAnim.setDuration(ANIMATION_DURATION);
    colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float mul = (Float) animation.getAnimatedValue();
            int alpha = adjustAlpha(activatedColor, mul);
            likesImageView.setColorFilter(alpha, PorterDuff.Mode.SRC_ATOP);
            if (mul == 0.0) {
                likesImageView.setColorFilter(null);
            }
        }
    });

    colorAnim.start();
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:21,代碼來源:LikeController.java

示例11: revealSides

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@OnClick({R.id.first,R.id.third})
public void revealSides(FloatingActionButton dot) {
    if (finished) {
        finished=false;
        lastDot = dot;
        float deltaX = topPanel.getWidth() / 2 - dot.getX() - dot.getWidth() / 2;
        float deltaY = topPanel.getHeight() / 2 - dot.getY() - dot.getHeight() / 2;
        deltaY -= topPanel.getHeight() / 2 + getResources().getDimension(R.dimen.morph_radius) / 4;
        Path arcPath = createArcPath(dot, deltaX, deltaY, -deltaX);
        ValueAnimator pathAnimator = ValueAnimator.ofFloat(0, 1);
        pathAnimator.addUpdateListener(new ArcListener(arcPath, dot));
        int dotColor=dot.getBackgroundTintList().getDefaultColor();
        topPanel.setBackgroundColor(dotColor);
        if(dotColor==color) {
            backgroundReveal().start();
        }
        pathAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                Animator animator = createRevealAnimator(dot, 0);
                finish(animator);
                animator.start();
                runCloseAnimation();
            }
        });
        AnimatorSet animatorSet = morphParent(duration(R.integer.reveal_duration));
        animatorSet.play(pathAnimator);
        addScaleAnimation(duration(R.integer.short_delay), duration(R.integer.fade_duration), animatorSet);
        animatorSet.start();
    }
}
 
開發者ID:vpaliyX,項目名稱:Material-Motion,代碼行數:33,代碼來源:DotsFragment.java

示例12: animateRevealHide

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void animateRevealHide(final View viewRoot) {
    View fab = MainActivity.of(getActivity()).fab;
    int cx = fab.getLeft() + (fab.getWidth()/2); //middle of button
    int cy = fab.getTop() + (fab.getHeight()/2); //middle of button
    int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, radius, 0);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            viewRoot.setVisibility(View.INVISIBLE);
        }
    });
    //anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(Navigator.ANIM_DURATION);
    anim.start();

    Integer colorTo = getResources().getColor(R.color.primaryColor);
    Integer colorFrom = getResources().getColor(android.R.color.white);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            overlayLayout.setBackgroundColor((Integer)animator.getAnimatedValue());
        }

    });
    colorAnimation.setInterpolator(new AccelerateInterpolator(2));
    colorAnimation.setDuration(Navigator.ANIM_DURATION);
    colorAnimation.start();
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:34,代碼來源:OverlayFragment.java

示例13: createFabIconTintAnimator

import android.animation.ValueAnimator; //導入方法依賴的package包/類
@NonNull
private ValueAnimator createFabIconTintAnimator(int[] colors) {
    ValueAnimator anim = newArgbValueAnimator(colors);
    anim.setDuration(FAB_ANIM_DURATION);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            DrawableCompat.setTintList(mOkButton.getDrawable(), ColorStateList.valueOf(
                    (int) animation.getAnimatedValue()));
        }
    });
    return anim;
}
 
開發者ID:philliphsu,項目名稱:NumberPadTimePicker,代碼行數:14,代碼來源:NumberPadTimePickerBottomSheetComponent.java

示例14: crossFade

import android.animation.ValueAnimator; //導入方法依賴的package包/類
public void crossFade(int duration) {
    ValueAnimator va = LauncherAnimUtils.ofFloat(0f, 1f);
    va.setDuration(duration);
    va.setInterpolator(new DecelerateInterpolator(1.5f));
    va.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mCrossFadeProgress = animation.getAnimatedFraction();
            invalidate();
        }
    });
    va.start();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:14,代碼來源:DragView.java

示例15: animateAlphaAtIndex

import android.animation.ValueAnimator; //導入方法依賴的package包/類
/**
 * Returns an animator which changes the alpha at the index {@param index}
 * to {@param finalAlpha}. Alphas at other index are not affected.
 */
public Animator animateAlphaAtIndex(float finalAlpha, final int index) {
    final ValueAnimator anim;

    if (Float.compare(finalAlpha, mAlphas[index]) == 0) {
        // Return a dummy animator to avoid null checks.
        anim = ValueAnimator.ofFloat(0, 0);
    } else {
        ValueAnimator animator = ValueAnimator.ofFloat(mAlphas[index], finalAlpha);
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float value = (Float) valueAnimator.getAnimatedValue();
                setAlphaAtIndex(value, index);
            }
        });
        anim = animator;
    }

    if (Float.compare(finalAlpha, 0f) == 0) {
        // In case when any channel is animating to 0, and the current alpha is also 0, do not
        // update alpha of the target view while the animation is running.
        // We special case '0' because if any channel is set to 0, values of other
        // channels do not matter.
        anim.addListener(new ZeroAlphaAnimatorListener());
    }
    return anim;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:32,代碼來源:MultiStateAlphaController.java


注:本文中的android.animation.ValueAnimator.addUpdateListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。