Animation动画操作

参考网站

http://www.cnblogs.com/sunzn/archive/2013/01/27/2878385.html

http://blog.csdn.net/chenzheng_java/article/details/6273954

http://blog.csdn.net/huangbiao86/article/details/6683665

http://blog.csdn.net/yuzhiboyi/article/details/7731826

ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, 

float pivotXValue, int pivotYType, float pivotYValue)

float fromX 动画起始时 X坐标上的伸缩尺寸
float toX 动画结束时 X坐标上的伸缩尺寸
float fromY 动画起始时Y坐标上的伸缩尺寸
float toY 动画结束时Y坐标上的伸缩尺寸
int pivotXType 动画在X轴相对于物件位置类型
float pivotXValue 动画相对于物件的X坐标的开始位置
int pivotYType 动画在Y轴相对于物件位置类型
float pivotYValue 动画相对于物件的Y坐标的开始位置

一、Animations从总体上来说可以分为两大类:

1、TweenedAnimations:该类提供了旋转,移动,伸展,和淡出竺效果;

2、Frame-by-FrameAmimations:这一类可以创建一个Drawable序列:这些Drawable可以按照指定的时间间歇一个一个的显示。


二、TwenedAnimations的分类

a)        Alpha:淡入淡出效果

b)        Scale:缩放效果

c)        Rotate:旋转效果

d)        Translate:移动效果

这四种动画效果对应四个不同的类,都有不同的参数,但是这四个不同的动画效果有共同的参数:下面简单介绍下面几种:

setDuration(long durationMills)设置动画持续时间,单位毫秒 ;

setFillAfter(boolean fillAfter)如果为true的话,动画执行后,控件停留在执行结束的状态;

setFillBefore(boolean fillBefore)

setStartOffSet(long startOffSet)设置动画执行之前等待时间;

setRepeatCount(int repeatCount)设置动画重复的次数

下面简单介绍一下,TewnedAnimation的使用步骤:

1、创建一个AnimationSet,存放动画集合,也可以只有一个动画。

2、根据需要创建对应的Animation

3、根据动画的需求,为Animation创建相对应的数据。

4、将Animation对象添加到AnimationSet

5、使用控件开始执行Animation:textView.startAnimation(AnimateionSet)当然里面的参数也可以是Animate,由于Animation是AnimationSet的父类,所以不会出错


三.模拟一个控件实现动画效果

1. imageView = (ImageView) findViewById(R.id.imageView_animation1);  
2.        imageView.setBackgroundResource(R.drawable.animation1_drawable);  
1.// 获取AnimationDrawable对象  
2.        AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground();  
3.          
4.        // 动画是否正在运行  
5.        if(animationDrawable.isRunning()){  
6.            //停止动画播放  
7.            animationDrawable.stop();  
8.        }  
9.        else{  
10.            //开始或者继续动画播放  
11.            animationDrawable.start();  
        } 

猜你喜欢

转载自blog.csdn.net/xxdw1992/article/details/81040317