「已注销」 2016-10-09 05:33 采纳率: 0%
浏览 909

安卓 简单的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条回答

  • qq_26531159 2016-10-09 08:25
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度