Android 启动屏幕在设置菜单页面之前先显示白色屏幕,然后显示黑色屏幕

Android 启动屏幕在设置菜单页面之前先显示白色屏幕,然后显示黑色屏幕,android,multithreading,android-layout,splash-screen,Android,Multithreading,Android Layout,Splash Screen,我的应用程序有一个带有动画徽标(使用线程)的启动屏幕,然后会显示一个菜单页面 现在我想在我的闪屏上做一些背景活动。也就是说,我想把一些图像转换成字符串等 我已将执行此操作的代码放在onCreate()函数中。但问题是,我看到的不是闪屏,而是一个空白的白屏,然后是一个黑屏。然后,过了一段时间,菜单页面将照常显示 如果我对后台处理的代码进行注释,它的功能将非常完美。此外,背景代码工作正常。只是他们在一起工作不正常。日志中没有错误,我无法知道是什么错误 启动屏幕的Java代码 public class

我的应用程序有一个带有动画徽标(使用线程)的启动屏幕,然后会显示一个菜单页面

现在我想在我的闪屏上做一些背景活动。也就是说,我想把一些图像转换成字符串等

我已将执行此操作的代码放在onCreate()函数中。但问题是,我看到的不是闪屏,而是一个空白的白屏,然后是一个黑屏。然后,过了一段时间,菜单页面将照常显示

如果我对后台处理的代码进行注释,它的功能将非常完美。此外,背景代码工作正常。只是他们在一起工作不正常。日志中没有错误,我无法知道是什么错误

启动屏幕的Java代码

public class Splash extends Activity {

protected int _splashTime = 10000; 

private Thread splashTread;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //MakeFolder(); 
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.splash);

         MakeFolder();   
    ImageView IM =(ImageView)findViewById(R.id.imageView2);

    final Animation mobianim = AnimationUtils.loadAnimation(this, R.anim.mobianim);

    IM.setAnimation(mobianim);
    mobianim.setDuration(1000);

    animate();
  //  AnimateLogo();


     final Splash sPlashScreen = this; 

    // thread for displaying the SplashScreen
    splashTread = new Thread() {
        @Override
        public void run() {
            try {                   
                synchronized(this){
                    wait(_splashTime);

                }


            } catch(InterruptedException e) {} 
            finally {
                finish();

                Intent i = new Intent();
                i.setClass(sPlashScreen, MenuPg.class);
                startActivity(i);


               // stop();
            }
        }
    };

    splashTread.start();



      /* 
              **Code for doing background things**

       */

}

public void MakeFolder(){
    File direct = new File(Environment.getExternalStorageDirectory() + "/MyFolder");

    if(!direct.exists())
     {
         if(direct.mkdir()){ //directory is created;

     }
    }
    }

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        synchronized(splashTread){
            splashTread.notifyAll();
        }
    }
    return true;
}


public void animate(){
        ImageView IV1=(ImageView)findViewById(R.id.imageView1);


        AlphaAnimation alphaAmin = new AlphaAnimation(0,1);
        IV1.setAnimation(alphaAmin);
        alphaAmin.setDuration(5000);

}
}
您的后台代码是在另一个线程中运行还是在UI线程中运行?
因为在onCreate方法完成之前,动画不会显示,所以这可能是错误的


您还可以在ImageView上使用startAnimation(动画),使其在该时刻开始。

您可以尝试删除同步(此)部分吗?您正在做的事情无论如何都不需要同步。您还可以在执行相同操作的UI线程上发布延迟的runnable(完成,开始下一个活动)。您可以像这样在imageView上发布它:IV1.postDelayed(runnable,\u splashTime);离题,但: