【问题标题】:Animation in splash screen android doesn't work properly启动屏幕android中的动画无法正常工作
【发布时间】:2013-08-10 12:42:44
【问题描述】:

我的斜线屏幕上有一个过渡,但有时动画会开始,而其他动画则不会。 我不明白如何解决这个问题,这里是带有 textview 动画的启动活动。奇怪的是有时它可以正常工作,特别是在模拟器上它比在设备上工作的次数更多。

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.splash_screen);

    title1 = (TextView)findViewById(R.id.textView1);        
    animation1 = AnimationUtils.loadAnimation(this,R.anim.long_slide_left);

    title1.startAnimation(animation1);

    new Handler().postDelayed(new Runnable() {
        public void run() {

            Intent intent = new Intent();
            intent.setClass(SplashScreenActivity.this, mainActivity.class);

            SplashScreenActivity.this.startActivity(intent);               

            SplashScreenActivity.this.finish();

            // transition from splash to main menu
            overridePendingTransition(R.anim.activityfadein,
                    R.anim.activityfadeout);

        }
    }, 1000);
}

【问题讨论】:

    标签: android animation startup splash-screen


    【解决方案1】:

    试试这个简单的线程,而不是处理程序。

    Thread splash=new Thread(){
                @Override
                public void run() {
    
                    try {
    
    
                            sleep(3000);
    
    
    
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }finally{
                        finish();
                        Intent i=new Intent(getBaseContext(), MainActivity.class);
                        startActivity(i);
                    }
                }
            };
            splash.start();
    

    【讨论】:

    • 问题仍然存在...我尝试移动“title1.startAnimation(animation1);”在 onResume 事件中,但有时如果我重复开始,动画不会开始。
    猜你喜欢
    • 2018-07-29
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多