今日,在学习AnimatorSet时,使用play、with、after、before时,代码书写如下:

ObjectAnimator animator1 = ObjectAnimator.ofFloat(v,"translationX",300f);
ObjectAnimator animator2 = ObjectAnimator.ofFloat(v,"scaleX",1f,0f,1f);
ObjectAnimator animator3 = ObjectAnimator.ofFloat(v,"scaleY",1f,0f,1f);
AnimatorSet set = new AnimatorSet();
set.setDuration(1000);
set.play(animator1).after(animator2).before(animator3).with(animator2);
set.start();

运行代码时,报错,错误报告如下:

12-12 16:26:18.210 28528-28528/com.zhangmiao.animationdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.zhangmiao.animationdemo, PID: 28528
java.lang.IllegalStateException: Circular dependencies cannot exist in AnimatorSet
at android.animation.AnimatorSet.sortNodes(AnimatorSet.java:921)
at android.animation.AnimatorSet.start(AnimatorSet.java:539)
at com.zhangmiao.animationdemo.ObjectAnimatorDemo.onClick(ObjectAnimatorDemo.java:82)
at android.view.View.performClick(View.java:4868)
at android.view.View$PerformClick.run(View.java:20294)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:192)
at android.app.ActivityThread.main(ActivityThread.java:5718)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:975)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

然后,我将set.play(animator1).after(animator2).before(animator3).with(animator2);代码修改为set.play(animator1);这时并不会报错,我依次添加动画,当添加到set.play(animator1).after(animator2).before(animator3).with(animator2);时,才会报错,所以是最后一个with(animator2)有问题,然后,我又添加了一个动画

ObjectAnimator animator4 = ObjectAnimator.ofFloat(v,"scaleY",1f,0f,1f);

将set.play(animator1).after(animator2).before(animator3).with(animator2);修改为

set.play(animator1).after(animator2).before(animator3).with(animator4);

代码就不会报错了。

所以,得到的结论是:

AnimatorSet的play、with、before、after函数不可复用同一个Animator,如果需要使用同样的Animator,可以创建多个相同动画的Animator,然后分别使用这多个动画即可。

Android之Dedug--Circular dependencies cannot exist in AnimatorSet的更多相关文章

  1. 开发问题及解决--java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android=" ...

  2. java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content&q ...

  3. android java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout

    造成这个问题的原因是在xml文件中出现了重复依赖,何为重复依赖,如下:   以上便叫重复依赖 转载请标明出处:http://www.cnblogs.com/tangZH/p/8386978.html

  4. Circular dependencies cannot exist in RelativeLayout

    循环布局错误!!! <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...

  5. Android Private Libraries 和 Dependencies的区别

    Android项目开发中,是不是常看到android-support-v4.jar.appcompat_v7.jar等的jar包? 至于为什么要添加这些包?添加有什么用?添加到哪里?相信很多人没过多关 ...

  6. springboot - SqlSessionFactoryBean falls in circular dependencies by Spring Boot's DataSourceInitializer

    springboot mybatis配置多数据源的时候,报错:There is a circular dependency between 7 beans in the application con ...

  7. Android Studio3.0中dependencies依赖由compile变为implementation的区别

    前言 Android Studio版本更新至3.0了,更新后,连带着com.android.tools.build:gradle 工具也升级到了3.0.0,在3.0.0中使用了最新的Gralde 4. ...

  8. Jackson-deserialization fails on circular dependencies(JackSon无限递归问题)

    Ok, so I'm trying to test some stuffs with jackson json converter. I'm trying to simulate a graph be ...

  9. android开发中遇到的问题汇总【九】

    244.http请求的url含有中字符时.须要Uri编码.Uri.encoder() 245.使用androidstudio时,不知道什么原因svn不见了 Android Studio missing ...

随机推荐

  1. .NET Core系列 :3 、使用多个项目

    通过前面的两篇文章,我们已经知道如何创建新的项目,如何生成并运行我们的应用程序,也知道(大致) project.json 文件中的内容是什么意思.但大多数项目往往也需要多个项目或引用的类库.我们要创建 ...

  2. .NET基础拾遗(5)多线程开发基础

    Index : (1)类型语法.内存管理和垃圾回收基础 (2)面向对象的实现和异常的处理基础 (3)字符串.集合与流 (4)委托.事件.反射与特性 (5)多线程开发基础 (6)ADO.NET与数据库开 ...

  3. 异常处理汇总 ~ 修正果带着你的Net飞奔吧!

    经验库开源地址:https://github.com/dunitian/LoTDotNet 异常处理汇总-服 务 器 http://www.cnblogs.com/dunitian/p/4522983 ...

  4. Angular企业级开发(1)-AngularJS简介

    AngularJS介绍 AngularJS是一个功能完善的JavaScript前端框架,同时是基于MVC(Model-View-Controller理念的框架,使用它能够高效的开发桌面web app和 ...

  5. iOS审核这些坑,腾讯游戏也踩过

    作者:Jamie,专项技术测试工程师,在iOS预审和ASO优化领域从事专项测试相关工作,为腾讯游戏近100个产品提供专项服务. WeTest 导读 在App上架苹果应用商店的过程中,相信大多数iOS开 ...

  6. Asp.Net WebApi核心对象解析(上篇)

    生活需要自己慢慢去体验和思考,对于知识也是如此.匆匆忙忙的生活,让人不知道自己一天到晚都在干些什么,似乎每天都在忙,但又好似不知道自己到底在忙些什么.不过也无所谓,只要我们知道最后想要什么就行.不管怎 ...

  7. 热修复-Nuwa学习篇

    nuwa热修复是基于qq空间团队的思路,最近的热度话题了,很多种方案,自己先研究几种方案,基本上都各有优势,学习肯定得先挑个软柿子捏了,自己对比了一下,发现nuwa代码量少点,所以就决定了,先研究nu ...

  8. can't run roscore 并且 sudo 指令返回 unable to resolve host

    I'm using ubuntu14 LTS. Problems: 1. When run roscore, got a mistake and an advice to ping the local ...

  9. Ubuntu 16.04 安装 arm-linux-gcc 嵌入式交叉编译环境 问题汇总

    闲扯: 实习了将近半年一直在做硬件以及底层的驱动,最近要找工作了发现了对linux普遍要求很高,而且工作岗位也非常多,所以最近一些时间在时不时地接触linux. 正文:(我一时兴起开始写博客,准备不充 ...

  10. Spring mvc @initBinder 类型转化器的使用

    一.单日期格式 因为是用注解完完成的后台访问,所以必须在大配置中配置包扫描器: 1.applicactionContext.xml <?xml version="1.0" e ...