android属性动画Animator(一)
来源:互联网 发布:淘宝ps4游戏商店 编辑:程序博客网 时间:2024/05/02 01:42
Animator是sdk 3.0之后加入的全新动画API,相比传统的Animation API ,属性动画有诸多优点。
Animation局限性:
1.传统Animation API 给ImageView添加动画,并在ImageVIew上监听click事件,执行Toast.makText(this,1,"在ImageView上点击!");
传统方式执行完动画后,我们发现,在ImageVIew上点击鼠标并不出现Toast提示,而是在ImageVIew的原来位置点击才显示Toast提示。这个就说面了Animation动画的局限性,Animation动画只适用显示性的动画,而不适合交互性的动画。
2.Animation的底层原理是不断调用重回方法,这种方式会占用大量CPU资源,会导致应用卡顿,而属性动画Animator只是修改元素的属性,因此会有更高的性能。
下面给出Animator的几种使用方式:
ImageView imageView = (ImageView) findViewById(R.id.iv_ic);/* * 传统动画方式 TranslateAnimation animation=new * TranslateAnimation(0,200,0,0); animation.setDuration(1000); * animation.setFillAfter(true);//设置图片动画结束后不恢复原位 * imageView.startAnimation(animation); */// 第一种方式:// ObjectAnimator.ofFloat(imageView, "translationX", 0F,// 200F).setDuration(1000).start();// ObjectAnimator.ofFloat(imageView, "translationY", 0F,// 200F).setDuration(1000).start();// ObjectAnimator.ofFloat(imageView, "rotation", 0F,// 360F).setDuration(1000).start();// 第二种方式ObjectAnimator animator1 = ObjectAnimator.ofFloat(imageView, "translationX", 0F, 200F);ObjectAnimator animator2 = ObjectAnimator.ofFloat(imageView, "translationY", 0F, 200F);ObjectAnimator animator3 = ObjectAnimator.ofFloat(imageView, "rotation", 0F, 360F);AnimatorSet set = new AnimatorSet();set.play(animator1).with(animator2);set.play(animator3).after(animator1);set.setDuration(1000);// set.playTogether(animator1,animator2,animator3); 一起执行动画// set.playSequentially(animator1, animator2, animator3); 按照给定的顺序执行动画set.start();// 第三种方式// ObjectAnimator.ofFloat(imageView, "translationX", 0F,// 200F).setDuration(1000).start();// ObjectAnimator.ofFloat(imageView, "translationY", 0F,// 200F).setDuration(1000).start();// ObjectAnimator.ofFloat(imageView, "rotation", 0F,// 360F).setDuration(1000).start();
0 0
- android属性动画Animator(一)
- android属性动画animator
- Android属性动画(Animator)
- Android 属性动画(一):Animator属性动画相对于Animation的优势
- Android之属性动画Animator
- Android Animator属性动画总结
- Android之Animator属性动画
- Android动画之属性动画Animator详解(卫星菜单)
- Animator参考(属性动画)
- Android 动画之属性动画(Animator)
- Android动画之(Property Animator(属性动画))
- Android Property Animator (属性动画)第一篇
- Android Property Animator (属性动画)第二篇
- Android Animator(Android动画)
- Android Animator(Android动画)
- Android-Animator属性动画( ObjectAnimator , AnimatorSet , ValueAnimator )
- Android——Animator笔记:属性动画
- 4.4.5 Android 属性动画Animator
- ShareSDK
- JPA 存储过程 事务 statement is closed.
- c#通过属性的名字获取值
- 网站架构(页面静态化,图片服务器分离,负载均衡)方案全解析
- 检测浏览器是否支持HTML5功能【转】
- android属性动画Animator(一)
- duilib模仿实现list ctrl的icon
- SASS框架
- SAT数学重点的备考题型都有哪些
- 动态规划 免费馅饼
- 4. 集中式vs分布式
- 黑马程序员-泛型理解
- 创建xml文件
- CountDownLatch的介绍和使用