//第一个参数:指定执行动画的控件,第二个参数:指定控件的属性,第三个参数是可变长参数
public static ObjectAnimator ofFloat(Object target, String propertyName, float... values)
动画过程监听
animator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float value = https://www.it610.com/article/(float) valueAnimator.getAnimatedValue();
Log.i("lgq",":ssss====="+value);
//动画过程监听
}
});
动画状态监听
animator2.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
Log.i("lgq",":ssss===onAnimationStart=111=");
}@Override
public void onAnimationEnd(Animator animator) {
Log.i("lgq",":ssss===onAnimationEnd==222");
animator2.setAutoCancel(false);
}@Override
public void onAnimationCancel(Animator animator) {
Log.i("lgq",":ssss===onAnimationCancel=333=");
animator.cancel();
}@Override
public void onAnimationRepeat(Animator animator) {
Log.i("lgq",":ssss===onAnimationRepeat=444=");
}
});
动画暂停
animator.pause();
动画重新开始
animator.resume();
动画重复次数
animator2.setRepeatCount(1);
组合动画方法:
AnimatorSet set = new AnimatorSet();
set.play(animator).with(animator3).with(animator2);
set.start();
//透明度动画
ObjectAnimator animator = ObjectAnimator.ofFloat(view,"alpha",1,0,1);
animator.setDuration(2000);
animator.start();
//旋转动画:围绕x轴旋转
ObjectAnimator animator = ObjectAnimator.ofFloat(tv,"rotationX",0,270,0);
animator.setDuration(2000);
animator.start();
//旋转动画:围绕y轴旋转
ObjectAnimator animator = ObjectAnimator.ofFloat(tv,"rotationY",0,180,0);
animator.setDuration(2000);
animator.start();
//旋转动画:围绕z轴旋转
ObjectAnimator animator = ObjectAnimator.ofFloat(tv,"rotation",0,270,0);
animator.setDuration(2000);
animator.start();
//平移动画:在x轴上平移
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "translationX", 0, 200, -200,0);
animator.setDuration(2000);
animator.start();
//平移动画:在y轴上平移
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "translationY", 0, 200, -100,0);
animator.setDuration(2000);
animator.start();
//缩放动画:在x轴缩放
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "scaleX", 0, 3, 1);
animator.setDuration(2000);
animator.start();
//缩放动画:在y轴上缩放
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "scaleY", 0, 3, 1);
animator.setDuration(2000);
animator.start();
推荐阅读
- 操作系统|[译]从内部了解现代浏览器(1)
- 程序员|DevEcoStudio的及其传感器的使用,闭关在家37天“吃透”这份345页PDF
- 图片加载框架之 ImageLoader
- OKHttp源码分析1 - 框架
- 移动开发|android 录屏方案 VFR和CFR
- 配置Android Studio的缓存文件路径(释放你的C盘)
- android Module之间数据传递
- 移动开发|Android入门(5)最简单的Handler例子
- 移动开发|我在达内学安卓-基于ArrayAdapter创建单一对象列表方式创建联系人列表!
- 移动开发|Android消息传递之EventBus 3.0使用详解