Property Animation
文章目录
一、概述
这些天看了很多开源项目的源码(自定义View方面),对属性动画也用的相对熟练一点了,下面就是对相关方法的一些总结:
二、常用方法总结
1 | /** *将指定的对象(target)的属性(propertyName)在值(values)间进行变换 **/ public static ObjectAnimator ofFloat(Object target, String propertyName, float... values){} /** *只指定变化的范围 **/ public static ValueAnimator ofFloat(float... values) {} |
1、ObjectAnimator继承自ValueAnimator,都有以下常用方法:
1 | anim.setDuration(1000);//1秒 anim.setRepeatCount(-1);//无线循环 anim.setInterpolator(new AccelerateDecelerateInterpolator());//插值器 anim.start();//开始动画 |
2、动画集:
1 | AnimatorSet set = new AnimatorSet(); set.playTogether(......); set.setDuration(1000); set.start(); //---------------------------------------------- set.plat().after(),with().befor();//相关方法 |
三、监听器
提供了2个监听器:
1 | //Animator的内部类 public static interface AnimatorListener { void onAnimationStart(Animator animation); void onAnimationEnd(Animator animation); void onAnimationCancel(Animator animation); void onAnimationRepeat(Animator animation); } |
1 | public static interface AnimatorUpdateListener { void onAnimationUpdate(ValueAnimator animation); } |