Tween Animation

通过对图片进行透明度,伸缩,rotation, 和移动的方式实现动画效果。通过预先定义的一组指令, 这些指令指定了图形变换的类型,出发时间,持续时间。程序沿着时间线就可以实现动画效果。

 

file location

res/anim/filename.xml

resource reference

in java: R.anim.filename

in XML: @anim/filename

 

推荐在xml中定义scale, rotate, alpha, transite. xml的根目录是single root的, root必须是<scale>,<rotate>,<translate>,<alpha>和<set>中的一个。 <set>可以 hold a group of other components include other <set>.

 

scale 的pivotX和pivotY表示图片中的一个点,这样图片就可以以这个点为中心进行伸缩,如果为(0,0)就表示是图片的左上定点,那么图片就向右下伸缩。pivotX和pivotY点在图片伸缩过程中remain fixed. android:fromXScale 表示开始时图片在x轴上的伸缩,1.0f表示图片大小不变。小于1.0为图片变小。

 

translate表示上下和(或)左右移动。如果图片起始点在(0,0), 开始translate时,如果在translate里设定移动起始点为(5,5),图片先移动到这个点再开始translate

支持三种格式 -100% ->100%: 表示a percentage relative to itself

                   -100%p -> 100%p表示a percentage relative to its parent

                    a float with no suffix 表示an absolute value

 

rotate的pivotX和pivotY可以是floot OR percentage

android:pivotX, 表示rotation的中心店坐标,如果是float表示距离图片的左边的x pixels的距离。%表示是在相对于左边x%的距离。%p表示相对于parent container的左边框的距离

 

android:pivotY表示与TOP的距离

 

Interpretors

在XML中定义用来改变图片 rate of change in an animation. 让当前的animation accelerated , repeated, bounced等。用android:interpolator形式添加给animation元素。 android中的所有的interpolator都是interpolator的子类。

@android:interpolator=“@android:anim/x_x_x”

其中 anticipate表示先往回缩

overshoot表示先多显示预定的final value再回到final value

accelerate是加速显示

decelerate减速显示

bounce在最后view震动

cycle设定重复显示动画几次

accelerateDecelerateInterpolator开始和结束时减速,中间加速

 

目前发现针对furfaceview的tween animation不好用,问题发生在onKeyUp里面,虽然所有的代码都能执行,可是屏幕没有效果。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值