安卓 简单的LOADING动画循环报错 求解决

public class MainActivity extends AppCompatActivity {

private ImageView img1, img2, img3, img4, img5, img6, img7;
private TextView mTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    img1 = (ImageView) findViewById(R.id.point1);
    img2 = (ImageView) findViewById(R.id.point2);
    img3 = (ImageView) findViewById(R.id.point3);
    mTextView = (TextView) findViewById(R.id.loading);
    final ObjectAnimator img1xstart = ObjectAnimator.ofFloat(img1, "scaleX", 1.0f, 1.5f);
    final ObjectAnimator img1ystart = ObjectAnimator.ofFloat(img1, "scaleY", 1.0f, 1.5f);
    final ObjectAnimator img1xend = ObjectAnimator.ofFloat(img1, "scaleX", 1.5f, 1.0f);
    final ObjectAnimator img1yend = ObjectAnimator.ofFloat(img1, "scaleY", 1.5f, 1.0f);
    final ObjectAnimator img2xstart = ObjectAnimator.ofFloat(img2, "scaleX", 1.0f, 1.5f);
    final ObjectAnimator img2ystart = ObjectAnimator.ofFloat(img2, "scaleY", 1.0f, 1.5f);
    final ObjectAnimator img2xend = ObjectAnimator.ofFloat(img2, "scaleX", 1.5f, 1.0f);
    final ObjectAnimator img2yend = ObjectAnimator.ofFloat(img2, "scaleY", 1.5f, 1.0f);
    final ObjectAnimator img3xstart = ObjectAnimator.ofFloat(img3, "scaleX", 1.0f, 1.5f);
    final ObjectAnimator img3ystart = ObjectAnimator.ofFloat(img3, "scaleY", 1.0f, 1.5f);
    final ObjectAnimator img3xend = ObjectAnimator.ofFloat(img3, "scaleX", 1.5f, 1.0f);
    final ObjectAnimator img3yend = ObjectAnimator.ofFloat(img3, "scaleY", 1.5f, 1.0f);
    final AnimatorSet animSet = new AnimatorSet();
    final AnimatorSet animSet2 = new AnimatorSet();
    final AnimatorSet animSet3 = new AnimatorSet();
    final AnimatorSet animSet4 = new AnimatorSet();
    animSet.play(img1xstart).with(img1ystart);
    animSet.setDuration(500);
    mTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            animSet.start();
            animSet.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    animSet2.play(img2xstart).with(img2ystart);
                    animSet2.play(img1xend).with(img1yend);
                    animSet2.setDuration(500);
                    animSet2.start();
                }
            });
            animSet2.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    animSet3.play(img3xstart).with(img3ystart);
                    animSet3.play(img2xend).with(img2yend);
                    animSet3.setDuration(500);
                    animSet3.start();
                }
            });
            animSet3.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    animSet.start();
                    animSet4.play(img3xend).with(img3yend);
                    animSet4.setDuration(500);
                    animSet4.start();
                    System.out.println("end");
                }
            });

        }
    });

}

}


这是我写的程序实现三个小圆点一次放大再缩小的动画循环执行 在第一个结束以后执行第二个 第二个结束之后执行第三个
然后第三个小圆点变大之后第一个小圆点再变大 就在第一个小圆点变大之后程序直接崩溃了
报错 java.lang.IllegalStateException: Circular dependencies cannot exist in AnimatorSet
求大神指点一下要怎么修改啊。。

2个回答

感觉让UI切图然后依次展示图片比这个要简单,这么做多麻烦

sld22525482
「已注销」 额,,能提供个小demo吗。。
接近 3 年之前 回复

你看看是不是控件被重复定义了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!