Android Studio中的PNG序列动画

时间:2017-10-10 05:33:46

标签: java android animation

所以我目前在我的oncreate中有这个代码。我真的想在用户使用png序列打开应用程序时立即创建动画。

0

和..

public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_home);
    view = (ImageView) findViewById(R.id.imageAnimation);
    view.setBackgroundResource(R.drawable.animation_list_filling);
    frameAnimation = (AnimationDrawable) view.getBackground();

我创建了一个xml文件

 @Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        frameAnimation.start();
    } else {
        frameAnimation.stop();
    }
}

但是一旦我运行应用程序,它就会继续崩溃。 Android Studio中没有错误。

0 个答案:

没有答案