加载AnimationDrawable 从xml file

 <animation-list   android:id="@+id/myprogress" android:oneshot="false"  
         xmlns:android="http://schemas.android.com/apk/res/android"> 
        <item android:drawable="@drawable/progress1" android:duration="150" /> 
        <item android:drawable="@drawable/progress2" android:duration="150" /> 
        <item android:drawable="@drawable/progress3" android:duration="150" /> 
     </animation-list> 

 

ImageView progress = (ImageView)findViewById(R.id.progress_bar); 
    if (progress != null) { 
        progress.setVisibility(View.VISIBLE); 
        AnimationDrawable frameAnimation = (AnimationDrawable)progress.getDrawable(); 
        frameAnimation.setCallback(progress); 
        frameAnimation.setVisible(true, true); 
    } 

 

<ImageView 
  android:id="@+id/progress_bar" 
  android:layout_alignParentRight="true" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:src="@drawable/myprogress" />

 

你可能感兴趣的:(xml,android)