Error while running new Drawable Animation on Android Stuido

Asked

Viewed 44 times

1

I have a problem. I created a test animation for a Splash Screen of a project of mine. It works well. Now when I made a new animation to subtype this old, out-of-nowhere app.

Animation 1 => Animation.xml, animation_01.png, animation_02.png, ... animation_06.png.

inserir a descrição da imagem aqui

corresponding xml =>

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/animation_01" android:duration="500"></item>
    <item android:drawable="@drawable/animation_02" android:duration="500"></item>
    <item android:drawable="@drawable/animation_03" android:duration="500"></item>
    <item android:drawable="@drawable/animation_04" android:duration="500"></item>
    <item android:drawable="@drawable/animation_05" android:duration="500"></item>
    <item android:drawable="@drawable/animation_06" android:duration="600"></item>

</animation-list>

Animation 02 => an.xml, an01.png, an02.png, ... an18.png.

inserir a descrição da imagem aqui

corresponding xml =>

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/an01" android:duration="150"></item>
    <item android:drawable="@drawable/an02" android:duration="150"></item>
    <item android:drawable="@drawable/an03" android:duration="150"></item>
    <item android:drawable="@drawable/an04" android:duration="150"></item>
    <item android:drawable="@drawable/an05" android:duration="150"></item>
    <item android:drawable="@drawable/an06" android:duration="150"></item>
    <item android:drawable="@drawable/an07" android:duration="150"></item>
    <item android:drawable="@drawable/an08" android:duration="150"></item>
    <item android:drawable="@drawable/an09" android:duration="150"></item>
    <item android:drawable="@drawable/an10" android:duration="150"></item>
    <item android:drawable="@drawable/an11" android:duration="150"></item>
    <item android:drawable="@drawable/an12" android:duration="150"></item>
    <item android:drawable="@drawable/an13" android:duration="150"></item>
    <item android:drawable="@drawable/an14" android:duration="150"></item>
    <item android:drawable="@drawable/an15" android:duration="150"></item>
    <item android:drawable="@drawable/an16" android:duration="150"></item>
    <item android:drawable="@drawable/an17" android:duration="150"></item>
    <item android:drawable="@drawable/an18" android:duration="500"></item>

</animation-list>

Here the code of Activity Splashscreen with the first animation that works.

package genesysgeneration.crushhelper;

import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

public class SplashScreenActivity extends AppCompatActivity {

    private ImageView ivInvisible;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);

        Thread myThread = new Thread(){

            @Override

            public void run(){

                try {

                    sleep(3000);
                    Intent it = new Intent(getApplicationContext(), MainMenuActivity.class);
                    startActivity(it);
                    finish();

                } catch (InterruptedException e) {

                    e.printStackTrace();

                }

            }

        };

        myThread.start();

        ivInvisible=(ImageView)findViewById(R.id.ivInvisible);
        ivInvisible.setBackgroundResource(R.drawable.animation);

        AnimationDrawable animation_01 = (AnimationDrawable)ivInvisible.getBackground();
        animation_01.start();

    }

}

To change animation I change the line ivInvisible.setBackgroundResource(R.drawable.animation); for ivInvisible.setBackgroundResource(R.drawable.an);. No error is accused, but when running on android virtual machine the application stops from nothing.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.