2012-10-17 13 views
0

在我的android應用程序中,我有一個放置在另一個視圖頂部的視圖。當我點擊一個按鈕時,這個頂視圖就會變成動畫並且不在屏幕上。問題在於它就像是視圖仍然「存在」,因爲它捕獲所有觸摸事件,並且它們不會傳遞到後面的視圖。查看仍然捕獲移動後的touche事件

這是一個動畫視圖客場代碼:

TranslateAnimation animation = new TranslateAnimation (0, 0, 0, height); 
animation.setDuration(1000); 
animation.setFillAfter(true); 
topView.startAnimation(animation); 

我能做些什麼來解決這個問題?

+0

http://stackoverflow.com/questions/4502580/view-still-there-but-not-visible-after-being-moved-out-by-animation –

+0

溶液提出有針對Android 3 +我正在使用2.2 –

回答

1

創建一個動畫監聽器,並在動畫結束時從其父視圖中移除該視圖。

Animation animation = new AlphaAnimation(0 ,0); 
     animation.setAnimationListener(new AnimationListener() { 

      public void onAnimationStart(Animation animation) { 
       // TODO Auto-generated method stub 

      } 

      public void onAnimationRepeat(Animation animation) { 
       // TODO Auto-generated method stub 

      } 

      public void onAnimationEnd(Animation animation) { 
       parentView.removeView(topView) 
      } 
     }); 
+0

It Works,謝謝 –

+0

很高興能夠提供幫助:) –