android 动画Animation之TranslateAnimation移动

TranslateAnimation详解

  Android JDK为我们提供了4种动画效果,分别是: AlphaAnimation,RotateAnimation, ScaleAnimation, TranslateAnimation.

  TranslateAnimation是移动的动画效果。它有三个构造函数,分别是:

  

public TranslateAnimation(Context context,AttributeSet attrs)  

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

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

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

  这个是我们最常用的一个构造方法,

  float fromXDelta:这个参数表示动画开始的点离当前View X坐标上的差值;

  float toXDelta, 这个参数表示动画结束的点离当前View X坐标上的差值;

  float fromYDelta, 这个参数表示动画开始的点离当前View Y坐标上的差值;

  float toYDelta)这个参数表示动画开始的点离当前View Y坐标上的差值;

 

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

        fromXType:第一个参数是x轴方向的值的参照(Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF,or Animation.RELATIVE_TO_PARENT);

  fromXValue:第二个参数是第一个参数类型的起始值;

  toXType,toXValue:第三个参数与第四个参数是x轴方向的终点参照与对应值;

  如果全部选择Animation.ABSOLUTE,其实就是第二个构造函数。

        以x轴为例介绍参照与对应值的关系:

         如果选择参照为Animation.ABSOLUTE,那么对应的值应该是具体的坐标值,比如100到300,指绝对的屏幕像素单位

         如果选择参照为Animation.RELATIVE_TO_SELF或者 Animation.RELATIVE_TO_PARENT指的是相对于自身或父控件,对应值应该理解为相对于自身或者父控件的几倍或百

         之多少。

posted @ 2013-07-25 18:42  kevin.m  阅读(1764)  评论(0编辑  收藏  举报