「已注销」 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 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值