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指的是相对于自身或父控件,对应值应该理解为相对于自身或者父控件的几倍或百

         之多少。

转载于:https://www.cnblogs.com/itkevin/p/3215039.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值