2013-10-30 21 views
0

我試圖在Android中應用淡入\出過渡。淡入出作品太短,太快在Android

你能告訴我爲什麼我看到衰落只有片刻,然後回到原來的阿爾法?

我已添加setFillAfter(true);以堅持圖像消失。

我曾嘗試:

   animation = android.view.animation.AnimationUtils 
         .loadAnimation(AppService.getAppContext(), 
           com.waze.R.anim.fade_out); 

       animation.setInterpolator(new AccelerateInterpolator()); 
       animation.setFillAfter(true); 
       boxImage_left.startAnimation(animation); 

與此:

<set xmlns:android="http://schemas.android.com/apk/res/android" 
      android:fillAfter="true"> 
    <alpha android:fromAlpha="0.0" 
     android:toAlpha="1.0" 
     android:repeatCount="0" 
     android:duration="500"/> 
</set> 

也:

   AlphaAnimation alpha = new AlphaAnimation(0,1); 
       alpha.setDuration(600); 
       animation.setInterpolator(new AccelerateInterpolator()); 
       animation.setFillAfter(true); 
       vImage_left.startAnimation(alpha); 

回答

0

讓你的活動實現AnimationListener和動畫結束後設置可視性。

public class YourActivity extends Activity implements AnimationListener 
{ 
    @override 
    onCreate(Bundle x) 
    { 
     ... 
     // set animation listener 
     animFadein.setAnimationListener(this); 
     animFadeOut.setAnimationListener(this); 

    } 
    @Override 
    public void onAnimationEnd(Animation animation) 
    { 
     if (animation == animFadein) 
     { 
      view.setVisibility(View.VISIBLE); 
     } 
     if (animation == animFadeOut) 
     { 
      view.setVisibility(View.INVISIBLE); 
     } 
    } 
} 

而對於動畫的速度修改動畫的持續時間和插