2011-08-31 96 views
2

我在我的xml文件中遇到了android:duration屬性的問題。 這是我的代碼:AnimationDrawable持續時間屬性

<animation-list 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:oneshot="false"> 
<item 
android:drawable="@drawable/eye_1" 
android:duration="150" /> 
<item 
. 
. 
. 
</animation-list> 

有8圖像。 這裏是我的活動代碼:

public class MyActivity extends Activity { 
    AnimationDrawable frameAnimation; 
    private MediaPlayer mp; 
    @Override 
     public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.sauron); 
     mp = MediaPlayer.create(this, R.raw.sound); 
     mp.setLooping(true); 
     mp.start(); 

     ImageView imgView = (ImageView) findViewById(R.id.animationImage); 
     // imgView.setVisibility(ImageView.VISIBLE); 
     imgView.setBackgroundResource(R.drawable.animation); 

     frameAnimation = (AnimationDrawable) imgView 
       .getBackground(); 


    // Get instance of Vibrator from current Context 
     Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); 
     v.vibrate(10000); 
    } 
    @Override public void onWindowFocusChanged(boolean hasFocus) { 
     frameAnimation.start(); 
     super.onWindowFocusChanged(hasFocus); } 

@Override 
    protected void onStop() 
{ 
    // Stop play 
    super.onStop(); 
    mp.stop(); 
} 
    } 

一切工作正常,但存在與圖像之間持續時間的問題。無論我在android:duration屬性中輸入什麼數字,動畫運行速度都非常快。有誰知道問題在哪裏?

謝謝

回答

0

的持續時間是在「毫秒」,這意味着150是非常非常快 當1500爲1.5秒,150指0.15秒其中僅有1第十一個第二

的嘗試把數以千計,如1500或3000,看看是否有效