2012-12-27 36 views
0

如何停止動畫(我認爲使用.stop())。那麼它應該是一張靜態的動畫圖片。第二張照片應該是所顯示的照片。動畫 - 停止動畫並顯示動畫中的特定圖像

我該怎麼做?

繼承人的XML動畫列表:

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:drawable="@drawable/app" android:duration="1200"/> 
<item android:drawable="@drawable/app2" android:duration="250"/> 
</animation-list> 

回答

0

我已經自己解決了這個問題,幾個小時後,研究。

Object tag = layout.getTag(); 
    int backgroundId = R.drawable.night; 

    if(tag != null && ((Integer)tag).intValue() == backgroundId) { 
     backgroundId = R.drawable.day; 
     playAnimation(); 
    } 
    else 
    { 
     animatedLoerg.selectDrawable(1); 
     animatedLoerg.stop(); 
    } 

    layout.setTag(backgroundId); 
    layout.setBackgroundResource(backgroundId); 

解決它的標籤。