D4rWiNS
D4rWiNS

Reputation: 2615

Animation on the start delayed Android

I have 3 animations that start at the begin of the activity, If I start it onCreate or onResume it get delayed and it doesn't seems smooth.

If I use the animations on post delayed it work perfect but This is not the correct way since I don't know how much time it takes to load the activity and it will work on some phones

Is there any way to correct this?

my actual code

    Handler handler=new Handler();
    Runnable r=new Runnable() {
        public void run() {
            Animation animacion = AnimationUtils.loadAnimation(MenuActivity.this, R.anim.right_to_left);
            animacion.setFillAfter(true);
            entrar.startAnimation(animacion);

            animacion= AnimationUtils.loadAnimation(MenuActivity.this, R.anim.right_to_left);
            animacion.setFillAfter(true);
            animacion.setStartOffset(150);
            cambiarCentro.startAnimation(animacion);

            animacion= AnimationUtils.loadAnimation(MenuActivity.this, R.anim.right_to_left);
            animacion.setFillAfter(true);
            animacion.setStartOffset(300);
            clases.startAnimation(animacion);
        }
    };
    handler.postDelayed(r, 500);

Upvotes: 0

Views: 486

Answers (1)

Marcin Orlowski
Marcin Orlowski

Reputation: 75629

If firing animation in onResume() is still too early, you may move you animation starting code to onPostResume():

protected void onPostResume ()

Called when activity resume is complete (after onResume() has been called).

Upvotes: 1

Related Questions