Android 启动画面一开始是白色的? [英] Android splash screen is white in the beginning?

查看:50
本文介绍了Android 启动画面一开始是白色的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我启动我的应用程序时,在出现闪屏之前我看到了几秒钟的白屏.

我想知道我的应用程序的大小是否会影响它(它是 17.7MB ).还是因为我的测试设备很旧(HTC Desire HD)并且数据太多而有点垃圾?

还是正常行为?或者也许问题出在我的代码中,如下所示...

清单的一部分:

 <意图过滤器><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></意图过滤器></活动><活动android:name=".MainActivity"android:label="@string/app_name"机器人:屏幕方向=肖像"android:windowSoftInputMode="adjustPan"android:configChanges="方向" ><意图过滤器><category android:name="android.intent.category.DEFAULT"/></意图过滤器></活动>

飞溅活动:

公共类 SplashView 扩展了 SherlockActivity {私人最终 int SPLASH_DISPLAY_LENGHT = 1000;@覆盖protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);getSupportActionBar().hide();setContentView(R.layout.splash_view);尝试 {RefreshRatingsTask urt = new RefreshRatingsTask();urt.execute();} 捕获(异常 e){//忽略}new Handler().postDelayed(new Runnable() {@覆盖公共无效运行(){Intent mainIntent = new Intent(SplashView.this,MainActivity.class);SplashView.this.startActivity(mainIntent);SplashView.this.finish();}}, SPLASH_DISPLAY_LENGHT);}}

谢谢

解决方案

Android 使用初始 Activity 的 Theme 来显示一个虚拟 Activity,同时它将您的应用程序加载到内存中.

使您的应用程序更小将有助于减少等待时间,使用主题设置启动画面的样式将使其不那么引人注目.

Cyril Mottier 的这篇博文提供了更多详细信息.>

When i launch my app, i see a white screen for couple of seconds before splash screen appears.

I am wondering if the size of my app can affect it ( it is 17.7MB ). Or is it because my testing device is old (HTC Desire HD) and a bit trashed with too much data in it?

Or it is normal behavior? Or maybe problem is in my code, which is below...

Part of the manifest:

    <activity android:name=".SplashView"
          android:noHistory="true"
          android:screenOrientation="portrait"
          android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" 
        android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation" >
        <intent-filter >
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Splash activity:

public class SplashView extends SherlockActivity {
private final int SPLASH_DISPLAY_LENGHT = 1000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getSupportActionBar().hide();
    setContentView(R.layout.splash_view);
    try {
        RefreshRatingsTask urt = new RefreshRatingsTask();
        urt.execute();
    } catch (Exception e) {
        // ignore
    }
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            Intent mainIntent = new Intent(SplashView.this,
                    MainActivity.class);
            SplashView.this.startActivity(mainIntent);
            SplashView.this.finish();
        }

    }, SPLASH_DISPLAY_LENGHT);
}
}

thanks

解决方案

Android uses the Theme of your initial Activity to show a dummy Activity whilst it loads your application into memory.

Making your app smaller will help reduce the length of the wait and using a Theme to set the style of the splash screen will make it less noticeable.

This blog post by Cyril Mottier has more details.

这篇关于Android 启动画面一开始是白色的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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