アニメーション効果のために first.png、second.png などの名前の描画可能なフォルダーに置かれた画像の別のフレームを使用し、一定の時間後にそれをロードすることができます。
animation_list.xmlを作成して配置します。
<?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/first" android:duration="210" />
<item android:drawable="@drawable/second" android:duration="210" />
<item android:drawable="@drawable/third" android:duration="210" />
<item android:drawable="@drawable/fourth" android:duration="210" />
<item android:drawable="@drawable/fifth" android:duration="210" />
<item android:drawable="@drawable/sixth" android:duration="210" />
</animation-list>
次に、MainActivity コード is.create imageview で、activity_main xml に yourImageView という名前を付けます。
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.widget.ImageView;
public class MainActivity extends Activity {
private AnimationDrawable frameAnimation;
private ImageView view;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Type casting the Image View
view = (ImageView) findViewById(R.id.yourImageView);
// Setting animation_list.xml as the background of the image view
view.setBackgroundResource(R.drawable.animation_list);
// Type casting the Animation drawable
frameAnimation = (AnimationDrawable) view.getBackground();
frameAnimation.start();
}
}