旋转后更改textview的文本取消我的动画

时间:2013-04-15 00:47:29

标签: android android-animation android-2.2-froyo

我需要在轮换后更改textview的文本。我执行此代码来旋转我的textview

RotateAnimation textAnim = new RotateAnimation(90, deg, text.getWidth() / 2, text.getHeight() / 2);
textAnim.setDuration(DURATION); 
textAnim.setFillAfter(true); 
text.startAnimation(textAnim);

之后,我需要更改textview的文本,以便在textView上使用setText。

当我执行setText时,我的旋转被取消。 我的文本视图就像我旋转之前一样。

你知道为什么以及如何解决它?

2 个答案:

答案 0 :(得分:2)

在代码中使用 AnimationListener

onAnimationEnd()中更改textview的文本。 e.g。

@Override
public void onAnimationEnd(Animation arg0) {
    textview.settext(" Your text");
}

答案 1 :(得分:1)

您可以为动画添加animationListener,并在onAnimationEnd方法

中更改textview中的文本
anim.setAnimationListener(new Animation.AnimationListener(){
@Override
public void onAnimationStart(Animation arg0) {
}           
@Override
public void onAnimationRepeat(Animation arg0) {
}           
@Override
public void onAnimationEnd(Animation arg0) {
}

});

相关问题