Android ObjectAnimator动画效果实现

ObjectAnimator.ofFloat(imageView, "rotation", 0f, 360f).setDuration(1000).start();

ofFloat参数:图片控件,动画效果属性,初始状态(浮点型),结束状态(浮点型)。

setDuration参数:动画时间(毫秒)。

动画属行:

1)translationX 和 translationY:这两个属性控制了View所处的位置,它们的值是由layout容器设置的,是相对于坐标原点(0,0左上角)的一个偏移量。

2)rotation, rotationX 和 rotationY:控制View绕着轴点(pivotX和pivotY)旋转。

3)scaleX 和 scaleY:控制View基于pivotX和pivotY的缩放。

4)pivotX 和 pivotY:旋转的轴点和缩放的基准点,默认是View的中心点。

5)x 和 y:描述了view在其父容器中的最终位置,是左上角左标和偏移量(translationX,translationY)的和。

6)aplha:透明度,1是完全不透明,0是完全透明。

多个动画同时显示

PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("alpha", 1f, 0f, 200f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleX", 1f, 0, 200f);
PropertyValuesHolder pvhZ = PropertyValuesHolder.ofFloat("scaleY", 1f, 0, 200f);
ObjectAnimator.ofPropertyValuesHolder(imageView, pvhX, pvhY,pvhZ).setDuration(1000).start();
ObjectAnimator animator1 = ObjectAnimator.ofFloat(imageView, "rotation", 0f, 360f);
ObjectAnimator animator2 = ObjectAnimator.ofFloat(imageView, "scaleX", 0f, 200f);
ObjectAnimator animator3 = ObjectAnimator.ofFloat(imageView, "scaleY", 0f, 200f);
AnimatorSet animSet = new AnimatorSet();
animSet.playTogether(animator1, animator2, animator3 );  //同时执行
//animSet.playSequentially(animator1, animator2, animator3 );  //顺序执行
animSet.setDuration(1000);  
animSet.start();     
/** 
* animator2,animator3同时执行 
* animator1接着执行 
*/  
AnimatorSet animSet = new AnimatorSet();  
animSet.play(animator2).with(animator3); 
animSet.play(animator1).after(animator3);  
animSet.setDuration(1000);  
animSet.start(); 

参考:Android 属性动画(Property Animation) 完全解析 (上)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

c小旭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值