Animation not working for my Android App

333 views Asked by At

Hey I am trying to replicate a animation similar to gif below but with thinner circles:

But my animation is not moving, its just static circles, this is the method I am using:

private void circleAnimation3(final Marker marker){
    final Circle circle2 = mMap.addCircle(new CircleOptions()
            .center(new LatLng(marker.getPosition().latitude,marker.getPosition().longitude))
            .strokeColor(Color.CYAN).radius(1000));

    animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorList = new ArrayList<Animator>();

    for(int i=0;i<rippleAmount;i++) {
        final ValueAnimator scaleXAnimator = ValueAnimator.ofFloat(1.0f);
        scaleXAnimator.setRepeatCount(ValueAnimator.INFINITE);
        scaleXAnimator.setRepeatMode(ValueAnimator.RESTART);
        scaleXAnimator.setStartDelay(i * (3000/6));
        scaleXAnimator.setDuration(3000);
        scaleXAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float animatedFraction = valueAnimator.getAnimatedFraction();
                Log.e("", "" + animatedFraction);
                circle2.setRadius(animatedFraction * 100);
            }
        });
        animatorList.add(scaleXAnimator);

        final ValueAnimator scaleYAnimator = ValueAnimator.ofFloat(1.0f);
        scaleYAnimator.setRepeatCount(ValueAnimator.INFINITE);
        scaleYAnimator.setRepeatMode(ValueAnimator.RESTART);
        scaleYAnimator.setStartDelay(i * (3000/6));
        scaleYAnimator.setDuration(3000);
        scaleYAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float animatedFraction = valueAnimator.getAnimatedFraction();
                Log.e("", "" + animatedFraction);
                circle2.setRadius(animatedFraction * 100);
            }
        });
        animatorList.add(scaleYAnimator);

        final ValueAnimator alphaAnimator = ValueAnimator.ofFloat(1.0f,0f);
        alphaAnimator.setRepeatCount(ValueAnimator.INFINITE);
        alphaAnimator.setRepeatMode(ValueAnimator.RESTART);
        alphaAnimator.setStartDelay(i * (3000/6));
        alphaAnimator.setDuration(3000);
        alphaAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float animatedFraction = valueAnimator.getAnimatedFraction();
                Log.e("", "" + animatedFraction);
                circle2.setRadius(animatedFraction * 100);
            }
        });
        animatorList.add(alphaAnimator);
    }

    animatorSet.playTogether(animatorList);
    animatorSet.start();
}

I am not sure why it is not moving :(

0

There are 0 answers