您可以在名为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
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();
}
}
嘿命名yourImageView!谢谢回答!但是,这已经是我所知道的了。 如果我们把你放在这里但现在而不是在drawable中的情况,first.png,second.png等现在存储在一个扩展APK中(一个Zip文件可以说main.1.com.example.app.obb )。 我还可以使它工作吗?我不介意在某处解压所需的文件。 – DeviousSiddy 2014-12-19 06:52:51