android笔记02 Animation之和ScaleAnimation

来源:互联网 发布:北京外景婚纱景点 知乎 编辑:程序博客网 时间:2024/05/18 19:45

TranslateAnimation用于位移动画.

构造函数:

Animation a = new TranslateAnimation(fromXType, fromXValue, toXType, toXValue,fromYType, fromYValue, toYType, toYValue);

图片起始位置开始移动,则fromXValue 和fromYValue都是0,且Type都是TranslateAnimation.ABSOLUTE.

左\上移为负,右\下移为正.

ScaleAnimation用于缩放动画.

构造函数:

Animation a = new ScaleAnimation(fromX, toX,fromY, toY);

参数都是相对于自身,例如:

Animation s = new ScaleAnimation(0, 1, 0, 1);

则图片从左上向右下放大,从无至有;

如果要调整缩放方向,使用

Animation a = new ScaleAnimation(fromX, toX,fromY, toY, pivotXType,pivotXValue, pivotYType, pivotYValue);

设置type 为Animation.RELATIVE_TO_SELF,后面的pivotXValue,pivotYValue用来控制方向.例如:

Animation ss = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0);

就是从右下向左上缩小至无.