2011-05-14 5 views

답변

15

AnimationDrawable을 사용할 수 있습니다. 코드

private AnimationDrawable anim; 
private void Animation() { 
     ImageView img = (ImageView)findViewById(R.id.simple_anim); 
     anim = (AnimationDrawable)img.getDrawable(); 
     img.post(run); 
    } 

    Runnable run = new Runnable() { 
     @Override 
     public void run() { 
      anim.start(); 
     } 
    }; 

이 사용이 당신의 ANIM 폴더에 레이아웃이

<animation-list android:id="@+id/animation" android:oneshot="false" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item android:drawable="@drawable/cloud" android:duration="25" /> 
    <item android:drawable="@drawable/frame1" android:duration="25" /> 
    <item android:drawable="@drawable/frame2" android:duration="25" /> 
</animation-list> 

같은 firstlevelanimation.xml 무언가를 창조

<ImageView android:id="@+id/simple_anim" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:layout_centerHorizontal="true" 
    android:src="@anim/firstlevelanimation" 
    /> 
관련 문제