2012-01-04 73 views
8

問題: 僅顯示動畫列表中的第一個元素。在res動畫列表不起作用 - 僅顯示第一個元素

動畫列表繪製文件/繪製:

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
android:oneshot="false" > 

    <item 
    android:drawable="@drawable/k2si" 
    android:duration="1000"/> 
    <item 
    android:drawable="@drawable/android" 
    android:duration="1000"/> 

</animation-list> 

啓動動畫:

ImageView image = (ImageView) findViewById(R.id.imageView1); 
    image.setBackgroundResource(R.drawable.screensaver_image); 
    ((AnimationDrawable) image.getBackground()).start(); 

Documentation(滾動幀動畫)

+0

你的drawables是什麼? – 2012-01-04 11:37:26

+1

你從哪裏調用start()方法。如果它在您的活動的onCreate它不會工作。 – MikeIsrael 2012-01-04 11:44:22

+0

@Mike - 是的,它在'onCreate()'。什麼是正確的生命週期方法來調用開始? – 2012-01-04 11:47:20

回答

-1

可以實現從佈局XML本身同樣的事情,

剛纔提到android:src="@drawable/rode_anim"這不過是你的自定義動畫列表繪製。

+0

動畫的Lollipop xml autostart無法正常工作。 – 2016-11-25 21:00:12