在Android应用程序闪屏 [英] Splash screen in Android Application

查看:174
本文介绍了在Android应用程序闪屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我修改一个开源的应用程序,并希望在启动画面添加到它, 能有人帮我呢?

I am modifying an open source application and want to add a splash screen to it, Can some one help me in it?

当出现黑屏2至3秒钟,然后出现在应用程序的应用开始.... 在C活性main.xml中开始的$ C $,我已经阅读了splash.xml文件应该被创建和线程的帮助下飞溅活动,主要活动应并行执行一些论坛。它是正确的做法...?

When the application starts a black screen appears for 2 to 3 seconds and then the application appears.... In the code the activity main.xml is started, I have read some forums that the splash.xml file should be created and with the help of threads splash activity and main activity should be executed parallel. Is it the right approach...?

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        instance = this;
        setContentView(R.layout.main);

这岂不是可能的,我修改main.xml中,把图像(闪)main.xml中,使其出现在那里?

#

Would it not be possible that I modify main.xml and put the image (splash) in main.xml so that it appears from there?

推荐答案

使用类闪屏为下

public class Splashscreen extends Activity {

private static final int SPLASH_DISPLAY_TIME = 3000; /* 3 seconds */

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    new Handler().postDelayed(new Runnable() {

        public void run() {

            Intent mainIntent = new Intent(Splashscreen.this,
                    MainActivity.class);
            Splashscreen.this.startActivity(mainIntent);

            Splashscreen.this.finish();
            overridePendingTransition(R.anim.mainfadein,
                    R.anim.splashfadeout);
        }
    }, SPLASH_DISPLAY_TIME);
}

}

**添加mainfadein.xml和放大器; splashfadeout.xml在水库 - >动画文件夹

**Add mainfadein.xml & splashfadeout.xml in res->anim folder

    <?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:fromAlpha="0.0"
        android:toAlpha="1.0"
        android:duration="1000">
</alpha>

splashfadeout.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator"
        android:zAdjustment="top"
        android:fromAlpha="1.0"
        android:toAlpha="0.0"
        android:duration="1000" >
</alpha>

并添加splash.xml刚刚添加的ImageView并将其作为画面+背景; urchoice的布局添加图片

并让SplashScreen类的启动,使所有其他类如家在清单文件

And make Splashscreen class as Launcher and make all other class as HOME in manifest file

这篇关于在Android应用程序闪屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆