android 动画之TranslateAnimation移动

基本的动画是很重要的,有时候达到醒目的作用。

讲下容易理解的方式

原型

TranslateAnimation(fromModeX,valueX,toModeX,toValueX, 
fromModeY,valueY,toModeY,toValueY)
RELATIVE_TO_SELF 自身宽高*value (value取值0-1)
RELATIVE_TO_PARENT 父节宽高*value(value取值0-1) 
-1表示往屏莫上方运动,1表示往屏幕底部方向运动,0布局原位置
ABSOLUTE 屏幕绝对像素值
// 往屏幕上方平移
mUpAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF,0.0, Animation.RELATIVE_TO_SELF, 0.0,Animation.RELATIVE_TO_SELF, 1.0, Animation.RELATIVE_TO_SELF,0.0);
mUpAction.setDuration(600);
// 往屏幕底部平移
mDownAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0,Animation.RELATIVE_TO_SELF, 0.0, Animation.RELATIVE_TO_SELF,0.0, Animation.RELATIVE_TO_SELF, 1.0);
mDownAction.setRepeatMode(Animation.REVERSE);
mDownAction.setDuration(600);
//btn_view.startAnimation(mUpAction);//开始动画

这是我粗浅的理解。

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注