转换动画与视图布局
问题描述:
我想做出translateAnimation在我的Android应用程序与下面的代码:转换动画与视图布局
TranslateAnimation anim = new TranslateAnimation(0,0,-400,0);
anim.setDuration(400);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
mlLinearLayout.clearAnimation();
mlLinearLayout.requestLayout();
mlLinearLayout.layout(mlLinearLayout.getLeft(), mlLinearLayout.getTop()+400, mlLinearLayout.getRight(), mlLinearLayout.getBottom());
}
});
anim.setInterpolator(new AccelerateInterpolator());
anim.setFillEnabled(true);
anim.setFillAfter(true);
anim.setFillBefore(false);
mlLinearLayout.startAnimation(anim);
active=false;
但是当这个动画做的LinearLayout中回到自己的出发地,即使我重建我的观点与新的立场。我该如何改变它?
答
我终于找到了解决办法:
TranslateAnimation anim = new TranslateAnimation(0,0,0,400);
anim.setDuration(400);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
mlLinearLayout.layout(mlLinearLayout.getLeft(), mlLinearLayout.getTop()+400, mlLinearLayout.getRight(), mlLinearLayout.getBottom());
}
});
anim.setFillEnabled(true);
anim.setFillAfter(false);
anim.setFillBefore(false);
mlLinearLayout.startAnimation(anim);
active=false;
正如我重建转换后我的观点,fillafter不是有用的,现在它没有滞后的工作完美跳!
从你的问题我猜,setFillAfter被设置为false,但显然它看起来像你正在设置它。 – Jameo 2013-03-25 14:16:04