0
我有一個「再次播放」按鈕和一個「主頁」按鈕。再次播放按鈕在遊戲結束時已經動畫。代碼如下所示在android中如何在另一個按鈕被按下時清除一個按鈕的動畫?
private void playagain(){
final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
animation.setDuration(500); // duration
animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely
animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in
final Button btn = (Button) findViewById(R.id.playagain);
btn.setVisibility(View.VISIBLE);
btn.bringToFront();
btn.startAnimation(animation);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
view.clearAnimation();
btn.setVisibility(View.INVISIBLE);
findViewById(R.id.home).performClick();
}
});
}
它動畫按鈕,停止動畫,並提出了在主屏幕上,但如果點擊主頁按鈕,然後我也想再次發揮按鈕變爲不可見並清除動畫。
v.clearAnimation();在homebutton的onclick方法中沒有清除動畫。我該如何解決這個問題?