繁体   English   中英

开始时的动画延迟了Android

[英]Animation on the start delayed Android

我有3个从活动开始时开始的动画,如果我在onCreate或onResume上启动它,则它会延迟并且看起来不流畅。

如果我在延迟发布时使用动画,它可以完美工作,但这不是正确的方法,因为我不知道加载该活动需要多少时间,并且可以在某些手机上运行

有什么办法可以纠正这个问题?

我的实际代码

    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);

如果在onResume()中触发动画还为时过早,则可以将动画起始代码移至onPostResume()

受保护的void onPostResume()

活动恢复完成时调用(在调用onResume()之后)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM