当你想以不同的方式移动图像时使用TranslateAnimation
语法
TranslateAnimation animation = new TranslateAnimation(StartinXscale,StartingYscale,EndXscale,EndYscale);
方法
animation.setDuration(millisecond);//move speed.
animation.setRepeatCount(int value);//how many time you want to move it from starting to ending position.
animation.setRepeatMode(int value);//mode like goto destination and return back to main position.
imageView.startAnimation(animation);//Start animation on imageView
我们可以在一次活动中两次使用上面的代码吗?
mycode的
private void animationAction() {
float StartX = 500.0f;
float StartY = -300.0f;
float EndX = -300.0f;
float EndY = 500.0f;
int i = 0;
for (i = 0; i <2; i++) {
TranslateAnimation animation = new TranslateAnimation(StartX,StartX + EndX, StartY, StartY + EndY);
animation.setDuration(3000);
animation.setRepeatCount(5);
animation.setRepeatMode(2);
animation.setFillAfter(true);
img_animation.startAnimation(animation);
EndX = 300.0f;
}
在MyCode结果中只执行一次
答案 0 :(得分:2)
user_datetime = Datetime.parse(users.signin).to_time.localtime