开始在Android中运行应用程序时,为什么会出现白屏1秒钟? [英] Why there is a white screen appears for 1sec when starting to run the apps in Android?
问题描述
当我单击应用程序图标并开始运行应用程序时,它将显示白屏1秒钟.
我不知道为什么.
有什么主意可以清除这个白屏并直接进入我的活动吗?
When I click the app icons and start to run the apps, it will appear a white screen for 1 sec.
I don't know why.
Is there any idea to clear this white screen and directly go to my activity?
推荐答案
黑色屏幕是窗口背景图片.
The white/black screen is the window background image.
例如,当显示您的onCreate()
运行,并且布局正在膨胀.可能需要一些时间,尤其是在需要读取,解码和缩放很多位图的情况下.
The window background is shown while e.g. your onCreate()
runs and your layouts are being inflated. It can take some time especially if there's a lot of bitmaps that need to be read, decoded and scaled.
更改主题是可行的,因为某些主题具有非默认的窗口背景.例如, Theme.Wallpaper
具有透明的背景.那里也有其他定义.本质上您想要的是:
Changing the theme works because some themes have a non-default window background. For example, Theme.Wallpaper
has a transparent background. There are other definitions there, too. Essentially what you want is:
<style name="YourTheme">
<item name="android:windowBackground">@null</item>
</style>
通过编程,您可以通过以下方式实现相同的目标
Programmatically you can achieve the same with
getWindow().setBackgroundDrawable(null);
位于活动onCreate()
的顶部.
(老问题,但又被另一个答案撞了,没有一个好的答案.)
(Old question but got bumped up by another answer and there wasn't a good answer.)
这篇关于开始在Android中运行应用程序时,为什么会出现白屏1秒钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!