posts - 189,comments - 115,trackbacks - 0

android animation 总结

变化率是个常数,即 f (x) = x.

方法:public float getInterpolation(float input)

AccelerateInterpolator--开始变化很慢,然后逐渐变快,即 f(x) = x*x 或者 f(x) = pow(x, 2*mFactor).

方法:public float getInterpolation(float input)

AccelerateDecelerateInterpolator--变化率开始和结束都很慢,但中间很快,即 f(x) = (cos ((x+1)*PI) / 2.0f) + 0.5f.

方法:public float getInterpolation(float input)

LinearInerpolator、AccelerateInterpolator, DecelerateInterpolator, AccelerateDecelerateInterpolator,CycleInterpolator 是 Interpolator 的子类,分别实现了匀速、加速、减速、变速、循环等效果。

AlphaAnimation

控制透明度

构造函数:

@param开始的透明度

@param结束的透明度

AlphaAnimation(float fromAlpha, float toAlpha)

方法:

willChangeBounds()                                     具体不详,不过其返回值是固定的都是false

willChangeTransformationMatrix()         false

ScaleAnimation

控制尺寸

构造函数:

@param开始时x方向的伸缩比列

@param结束时x方向的伸缩比列

@param开始时y方向的伸缩比列

@param结束时y方向的伸缩比列

ScaleAnimation(float fromX, float toX, float fromY, float toY)

@param动画在x轴的伸缩位置0%-100%中取值,50%为物件的X或Y方向坐标上的中点位置

@param动画在y轴的伸缩位置

ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)

@param  pivotXType动画在X轴相对于物件位置类型--固定的一些数据

@param  pivotYType动画在X轴相对于物件位置类型

pivotXValue,pivotYValue同上面的pivotX,pivotY

ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)

方法:

     initialize(int width, int height, int parentWidth, int parentHeight)设置动画的大小根据父类的维数(猜测)

TranslateAnimation

移动

构造函数:

@param开始时x的位置

@param结束时x的位置

@param开始时y的位置

@param结束时y的位置

TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)

@param参考上面ScaleAnimation的

TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,int fromYType, float fromYValue, int toYType, float toYValue)

方法:

@param同ScaleAnimation的

initialize(int width, int height, int parentWidth, int parentHeight)

RotateAnimation

旋转

构造函数:

@param开始的角度

@param结束的角度

RotateAnimation(float fromDegrees, float toDegrees)

@param动画在x轴的旋转位置

@param动画在x轴的旋转位置

RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)

方法:

@param同ScaleAnimation的

         initialize(int width, int height, int parentWidth, int parentHeight)

Animation

抽象类,所有控制动画的都继承与该类

Aniamtion 是基类,他记录了动画的通用属性和方法。主要的属性包括动画持续时间、重复次数、interpolator等。

方法:---只列举了几个方法,用法很简单,可以去看sdk

getTransformation (currentTime, outTransformation)

该方法根据当前时间 (currentTime) 和 interpolator,计算当前的变换,在 outTransformation 中返回。

setRepeatMode(int)—在测试AnimationSet是该函数没有成功,可能有什么地方设置错了,以后再跟进

@param Animation.RESTART回到动作开始时的坐标,Animation.REVERSE反转的意思,a->b,在从b->a,Animation.INFINITE不断重复该动作

设置动作结束后,将怎样处理,只有在repeatCount大于0或为INFINITE的时候setRepeatMode才会生效

TranslateAnimation、RotateAnimation、AlphaAnimation、ScaleAnimation等是Animation的子类,分别实现了平移、旋转、改变透明度、缩放等动画。

AnimationSet

设置一个动画组,就是将一系列动作合在一起形成新的动画

可以包含多个Animation,但都是在同一个时间执行的,是并行,不是串行执行的。如果AnimationSet中有一些设定,如duration,fillBefore等,它包含的子动作也设定了的话,子动作中的设定将会给覆盖掉。

构造函数:

     @param是否公用动画插入器,为true表示共用AnimationSet的插入器

AnimationSet(boolean shareInterpolator)

方法:==

     @param为true时将在播放完后被应用,播完后停在最后一幅画上,这里重写了Animation的该方法,其他的基本上都是直接使用父类的

     setFillAfter(boolean fillAfter)

@param为true时将在开始前被应用,播完后停在第一幅画上,好像不设置该属性也会停留在最开始的那副上面

setFillBefore(boolean fillBefore)

@param在使用AnimationSet的重复mode时,还没有看到有什么效果,但是它的解释和Animation的该方法是一样的

setRepeatMode(int repeatMode)

@param动画停留时间间隔,从上次结束后停留多长时间进入下一次动画

setStartOffset(long startOffset)

@param添加动画

addAnimation(Animation a)

Example

AnimationSet aa = new AnimationSet(true);

    Animation myAnimaton = new TranslateAnimation(0,100,0,100); 

    aa.addAnimation(myAnimaton);

    Animation myAnimaton1 = new RotateAnimation(0,360);

    aa.addAnimation(myAnimaton1);

    myImage.startAnimation(aa);

    aa.start();

    aa.setDuration(2000);

aa.setFillAfter(true);

AnimationUtils

该类没有父类,动画的辅助类.构造函数也没有,使用默认的

方法:

@param可以看到不需要实例化该对象就可以使用,通过资源xml获得一个动画

static Animation loadAnimation(Context context, int id)

TranslateAnimation manmation = (TranslateAnimation)AnimationUtils. loadAnimation(this,R.anim.animation);

@param

LayoutAnimationController loadLayoutAnimation(Context context, int id)

LayoutAnimationController

Layout animation controller is used to animated a layout's, or a view group's, children.

该类和其衍生类GridLayoutAnimationController,GridLayoutAnimationController.AnimationParameters等还没有看到相关资料,也没有用过

Animation.Description

Utility class to parse a string description of a size. 

GridLayoutAnimationController

A layout animation controller is used to animated a grid layout's children.

GridLayoutAnimationController.AnimationParameters

The set of parameters that has to be attached to each view contained in the view group animated by the grid layout animation controller.

LayoutAnimationController.AnimationParameters

The set of parameters that has to be attached to each view contained in the view group animated by the layout animation controller.

Transformation                                                                      

Defines the transformation to be applied at one point in time of an Animation.

在xml文件中设置动画可以参考android_xml文件中介绍的,有实例解释

 

AlphaAnimation
 渐变透明度动画效果
 
ScaleAnimation
 渐变尺寸伸缩动画效果
 
TranslateAnimation
 画面转换位置移动动画效果
 
RotateAnimation
 画面转移旋转动画效果
 

transition设置两张图片的过渡,好像只能设置两张之间的过渡,多设置几张也只显示前面两张


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lishubing1126/archive/2009/12/02/4926770.aspx

posted on 2010-08-26 20:14 MEYE 阅读(1896) 评论(0)  编辑  收藏 所属分类: Android3D

只有注册用户登录后才能发表评论。


网站导航: