Android补间动画(TweenedAnimations)详解
2015-11-26 11:11
441 查看
一、直线
// 1、new对象(几种方式)/**
*参数一fromXDelta(x轴,起始的位置)
*参数二toXDelta(x轴,到达的位置) 参数三四,为y轴
*/
TranslateAnimation animation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
/**
*fromXType 相对运动的类型,一般为Animation.RELATIVE_TO_SELF(相对自己)
*fromXValue 起始位置,这里注意,是倍数关系
*toXType 一般为Animation.RELATIVE_TO_SELF
*toXValue 终点位置,这里注意,是倍数关系
*fromYType fromYValue toYType toYValue
*/
TranslateAnimation animation = new TranslateAnimation(fromXType, fromXValue, toXType, toXValue, fromYType, fromYValue, toYType, toYValue);
//2、关键的一些设置
animation.setDuration(3000);// 设置播放时间
animation.setRepeatCount(1);//设置重复的次数
animation.setRepeatMode(Animation.REVERSE );//设置重复播放的mode
,REVERSE是相反,默认设置是RESTART从头播放一次
animation.setFillAfter(true);//设置动画后保留在终止的位置,这是只是显示位置变了,实际的属性没变(如果有点击事件,要设置setEnabled(false))
//3、start
View.startAnimation(animation);
二、大小(缩放)
// 1、new对象(几种方式)/**
*fromX 这里是倍数关系,从原来的x(view的宽度)的多少倍开始
*toX 这里是倍数关系,到原来的x(view的宽度)的多少倍结束
*fromY 这里是倍数关系,从原来的y(view的高度)的多少倍开始
*toY 这里是倍数关系,到原来的y(view的宽度)的多少倍结束
*/
ScaleAnimation animation = new ScaleAnimation(fromX, toX, fromY, toY);
/**
*fromX toX fromY toY
*pivotX 缩放的中心位置(相对于左上角x轴的位置),中间的为View.getWidth()/2;
*pivotY 缩放的中心位置(相对于左上角y轴的位置) , 中间的为View.getHeight()/2;
*/
ScaleAnimation animation = new ScaleAnimation(fromX, toX, fromY, toY, pivotX, pivotY);
/**
*fromX toX fromY toY
*pivotXType 一般为Animation.RELATIVE_TO_SELF
*pivotXValue 这里是倍数,中间的换直接填0.5f
*pivotYType 一般为Animation.RELATIVE_TO_SELF
*pivotYValue 这里是倍数,中间的换直接填0.5f
*/
ScaleAnimation animation = new ScaleAnimation(fromX, toX, fromY, toY, pivotXType, pivotXValue, pivotYType, pivotYValue);
//2、关键的一些设置(同上)
//3、start (同上)
三、透明
// 1、new对象(几种方式)/**
107b4
*fromAlpha 起始透明度,取值是0~1 (0是完全透明,1是完全不透明)
*toAlpha 终止透明度
*/
AlphaAnimation animation = new AlphaAnimation(fromAlpha, toAlpha);
//2、关键的一些设置(同上)
//3、start (同上)
四、旋转
// 1、new对象(几种方式)/** 和(缩放)一样的
*fromDegrees 起始的角度,0~360
*toDegrees 终止的角度,0~360
*/
RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees);
/** 和(缩放)一样的
*fromDegrees 起始的角度,0~360
*toDegrees 终止的角度,0~360
*pivotX 旋转的中心位置(相对于左上角x轴的位置),中间的为View.getWidth()/2;
*pivotY 旋转的中心位置(相对于左上角y轴的位置) , 中间的为View.getHeight()/2;
*/
RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, pivotX, pivotY);
/** 和(缩放)一样的
*fromDegrees 起始的角度,0~360
*toDegrees 终止的角度,0~360
*pivotXType 一般为Animation.RELATIVE_TO_SELF
*pivotXValue 这里是倍数,中间的换直接填0.5f
*pivotYType 一般为Animation.RELATIVE_TO_SELF
*pivotYValue 这里是倍数,中间的换直接填0.5f
*/
RotateAnimation animation = new RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue);
//2、关键的一些设置(同上)
//3、start (同上)
五、动画一起放
AnimationSet set = new AnimationSet(false); //填false就好set.addAnimation(animation1);
set.addAnimation(animation2);
set.addAnimation(animation3);
set.addAnimation(animation4);
iv.startAnimation(set);
相关文章推荐
- FlipViewPager 对item实现左右对折滑动翻页效果《IT蓝豹》
- cocos2dx3.0无法取消Armatrue骨骼动画中的补间效果问题的解决办法
- Android的帧动画补间动画,新手复习
- android实现alpha渐变动画效果
- android实现scale伸缩动画效果
- android实现translate位移动画效果
- android下Rotate旋转动画实现效果
- Android Animation之补间动画
- Android 补间动画Animation的实用应用
- 安卓三种动画小结
- 【Android】属性动画
- Android-补间动画效果
- android animation
- Android ViewAnimation(tween animation补间动画)文档教程
- Android动画之补间动画(Tween Animation)
- android动画浅析
- Android动画机制(1):帧动画、补间动画详解及实战演练
- Android动画总结系列(3)——补间动画源码分析
- Android动画总结系列(2)——补间动画使用
- Android学习之动画(一)