我希望在加载资源时将动画图像(当前使用的一组PNG)显示为启动画面.
我已经能够使用它显示启动画面.但问题是:启动画面显示指定的时间,然后有一个黑屏,持续2-3秒,然后index.html加载.
理想情况下,我想要的是在资源加载时显示启动画面.加载资源后,拉动启动画面并立即加载index.html文件.
以下是我的代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Splash screen view
setContentView(R.layout.splash);
// Start animating the image
final ImageView splashImageView = (ImageView) findViewById(R.id.SplashImageView);
splashImageView.setBackgroundResource(R.drawable.flag);
final AnimationDrawable frameAnimation = (AnimationDrawable)splashImageView.getBackground();
splashImageView.post(new Runnable(){
@Override
public void run() {
frameAnimation.start();
}
});
final SplashScreen sPlashScreen = this;
// The thread to wait for splash screen events
mSplashThread = new Thread(){
@Override
public void run(){
try {
synchronized(this){
// Wait given period of time …Run Code Online (Sandbox Code Playgroud)