2017-04-24 46 views
0

我在我的代碼中有一個動畫。但我希望當我點擊按鈕我的ImageView返回到原來的地方(重置動畫)我有一個方法。我的代碼是:ImageView中的延遲清除動畫

private void returnToOriginalRotationState() { 
    RotateAnimation animation = new RotateAnimation(0.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); 
    animation.setInterpolator(new LinearInterpolator()); 
    animation.setDuration((long) 2*1000); 
    animation.setFillAfter(true); 
    animation.setFillEnabled(true); 
    imgHeade.startAnimation() } 

它的工作原理以及 但 animation.setDuration((長)2 * 1000);

不工作!!!

android-animation

+0

執行'imgHeade.setAnimation(動畫);'然後運行動畫。 – azizbekian

+0

謝謝,我用imgHeade.setAnimation(動畫);但動畫未運行 –

回答

0

這是你想要執行的動畫嗎?

new RotateAnimation(0.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); 

看來所有的度數都是0.0f

+0

是的,我想將我的ImageVIew放在原始位置,因爲當我提示按鈕ImageView移動到新的RotateAnimation(0,19, Animation.RELATIVE_TO_SELF,0, Animation.RELATIVE_TO_SELF,0);此代碼也可以工作 –

+0

現在我想讓我的ImageView回到原來的位置。 –

+0

你需要使用19某處返回動畫才能正常工作 –