TranslateAnimation
是平移动画。
TranslateAnimation
有三个构造方法:
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)
示例:
TextView textView = (TextView) findViewById(R.id.text_view);
TranslateAnimation translateAnimation = new TranslateAnimation(0, 100, 0, 100);
translateAnimation.setDuration(2000);
translateAnimation.setFillAfter(true);
translateAnimation.setInterpolator(new LinearInterpolator());
textView.startAnimation(translateAnimation);
在res/anim
目录中存放的xml
文件,以translate
作为根元素。
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)