2015-01-08 106 views
0

我想在我的編程中使用動畫,但它在仿真器上看不到。它在動畫資源之前打開MenuActivity類。Android動畫顯示問題

這裏是代碼分區;

Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_in); 
    ImageView girisLogo = (ImageView)findViewById(R.id.girisLogoImageView); 
    anim.reset(); 
    girisLogo.clearAnimation(); 
    girisLogo.startAnimation(anim); 

    anim.setAnimationListener(new AnimationListener() { 

     @Override 
     public void onAnimationStart(Animation animation) { 
      Intent intent = new Intent(GirisActivity.this,MenuActivity.class); 
      startActivity(intent); 
      GirisActivity.this.finish(); 
     } 

     public void onAnimationRepeat(Animation animation) {} 
     public void onAnimationEnd(Animation animation) {} 
    }); 
} 

fade_in.xml:

<set xmlns:android="https://schemes.android.com/apk/res/android"> 
    <alpha 
     android:fromAlpha = "0.0" 
     android:toAlpha="1.0" 
     android:interpolator="@android:anim/accelerate_interpolator" 
     android:duration="4000" 
    /> 

</set> 

我試圖用anim.serDuration(400);但結果不會改變。 你能幫我解決這個問題嗎?

回答

0

變化fade_in.xml

<?xml version="1.0" encoding="utf-8"?> 
<alpha xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fromAlpha="0.0" 
    android:toAlpha="1.0" 
    android:interpolator="@android:anim/accelerate_interpolator" 
    android:duration="4000" /> 

另外,如果您想在新活動啓動時動畫結束,將代碼放在onAnimationEnd()

+0

感謝您的幫助,動畫看到。 – ugurgog