<?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/p1" android:duration="400" />
<item android:drawable="@drawable/p2" android:duration="400" />
<item android:drawable="@drawable/p3" android:duration="400" />
<item android:drawable="@drawable/p4" android:duration="400" />
<item android:drawable="@drawable/p5" android:duration="400" />
<item android:drawable="@drawable/p6" android:duration="400" />
<item android:drawable="@drawable/p7" android:duration="400" />
<item android:drawable="@drawable/p8" android:duration="400" />-->
<item android:drawable="@drawable/p9" android:duration="400" />
<item android:drawable="@drawable/p10" android:duration="400" />
<item android:drawable="@drawable/p11a" android:duration="500" />
<item android:drawable="@drawable/p11b" android:duration="500" />
<item android:drawable="@drawable/p11c" android:duration="500" />
</animation-list>
public class EntActivity extends AppCompatActivity {
private AnimationDrawable frameAnimation;
private ImageView view;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ent);
// 컨트롤 ImageView 객체를 가져온다
view = (ImageView) findViewById(R.id.img);
// animation_list.xml 를 ImageView 백그라운드에 셋팅한다
view.setBackgroundResource(R.drawable.animation_list);
// 이미지를 동작시키기위해 AnimationDrawable 객체를 가져온다.
frameAnimation = (AnimationDrawable) view.getBackground();
}
// 어플에 포커스가 가면 동작한다
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// 어플에 포커스가 갈때 시작된다
frameAnimation.start();
} else {
// 어플에 포커스를 떠나면 종료한다
frameAnimation.stop();
}
}