今日,在学习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. PowerShell过滤文件中的重复内容

    Get-Content -Path E:\test11\data.txt | Sort-Object | Get-Unique 源文件: AA0001 2014-06-30 15:27:13.073 ...

  2. Oracle 数据库知识汇总篇

    Oracle 数据库知识汇总篇(更新中..) 1.安装部署篇 2.管理维护篇 3.数据迁移篇 4.故障处理篇 5.性能调优篇 6.SQL PL/SQL篇 7.考试认证篇 8.原理体系篇 9.架构设计篇 ...

  3. Android实现TCP断点上传,后台C#服务实现接收

    终端实现大文件上传一直都是比较难的技术,其中涉及到后端与前端的交互,稳定性和流量大小,而且实现原理每个人都有自己的想法,后端主流用的比较多的是Http来实现,因为大多实现过断点下载.但稳定性不能保证, ...

  4. 基于Composer Player 模型加载和相关属性设置

    主要是基于达索软件Composer Player.的基础上做些二次开发. public class ComposerToolBarSetting { public bool AntiAliasingO ...

  5. Unable to create the selected property page. An error occurred while automatically activating bundle net.sourceforge.pmd

    解决方案: 在命令行到eclipse目录下使用 eclipse.exe -clean

  6. java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INSTANCE

    Android发出HTTP请求时出现了这个错误: java.lang.NoSuchFieldError: org.apache.http.message.BasicLineFormatter.INST ...

  7. java中的移位运算符:<<,>>,>>>总结

    java中有三种移位运算符 <<      :     左移运算符,num << 1,相当于num乘以2 >>      :     右移运算符,num >& ...

  8. centos 6 安装配置openvpn

    下载地址:http://swupdate.openvpn.org/community/releases/http://www.oberhumer.com/opensource/lzo/download ...

  9. 免费开源的 .NET 分布式组件库 Exceptionless Foundatio

    前言 在互联网时代,分布式应用.系统变得越来越多,我们在使用 .Net 技术构建分布式系统的时候,需要使用到一些组件或者是助手库来帮助我们提高生产力以及应用程序解耦,但是纵观.Net圈,能够符合要求的 ...

  10. 【Java并发编程实战】-----“J.U.C”:Exchanger

    前面介绍了三个同步辅助类:CyclicBarrier.Barrier.Phaser,这篇博客介绍最后一个:Exchanger.JDK API是这样介绍的:可以在对中对元素进行配对和交换的线程的同步点. ...