Android 启动画面/加载画面

发布于 2024-09-15 21:17:02 字数 212 浏览 1 评论 0原文

我有一个启动屏幕/加载屏幕,在我的大位图的绘制调用完成后,.setVisibility() 立即消失。问题是启动屏幕需要一点时间才能弹出,我相信这是由于主要活动启动并在第一次运行时执行 CPU 密集型应用程序所致。有没有办法让我的启动画面尽快显示?如果我把它放在不同的线程中可以吗?初始屏幕只是一个位图,其下方有一个进度条。我的布局是基于 xml 的,所以我看不到自己使用 setContentView。谢谢。

I have a splash screen/loading screen that has .setVisibility() to GONE right after the draw call of my large bitmap is completed. The problem is the splash screen takes a bit to popup which i believe is due to the main activity booting up and doing CPU intensive applications on first run. Is there a way to get my splash screen displayed ASAP? Would it be ok if i had it in a different thread maybe? The splash screen is just a bitmap with a progressBar right below it. My layout is xml based so i cant see myself using setContentView. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

记忆で 2024-09-22 21:17:02

如果我把它放在不同的线程中可以吗?

在android中,当我们构建一个应用程序时,我们可能需要显示一个启动屏幕(欢迎屏幕),以便用户提示一些事情和信息。在后台执行一些其他进程(例如从数据库获取数据、解析XML等),因此最好在不同的线程中实现它。

我已经在 www.androidpeople.com 网站上引用了 SPLASH SCREEN 的示例,您也可以看看这个启动屏幕示例

Would it be ok if i had it in a different thread maybe?

In android, when we build an application we may need to display a splash screen ( welcome screen ) for users to intimate some thing & do some other process in background ( like fetching data from DB, Parsing XML , etc.. ), so for that it is preferrable to implement it in a different thread.

I have referred the example on www.androidpeople.com site for the SPLASH SCREEN, you may also Have a look at this example of SPLASH SCREEN .

度的依靠╰つ 2024-09-22 21:17:02

您希望有一个单独的线程在后台执行任务,同时在前台显示进度并在执行此操作后调用您所说的 setVisibility(...) 方法。

我遇到过这个教程: http:// /www.41post.com/4588/programming/android-coding-a-loading-screen-part-1

我发现它非常好,很容易实现,只需一堂课,在第 2 部分之后您将了解如何真正彻底摆脱 AsyncTask (http://stackoverflow.com/questions/3077461/asynctask-threads-never-die-android)。

You want a separate thread to execute tasks in background, while showing progress in the foreground and call the setVisibility(...) method you say after doing so.

I've come across this tutorial: http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1

I've found it excellent, it's easy to implement, only one class and after part 2 you learn how to really get rid of the AsyncTask definitevely (http://stackoverflow.com/questions/3077461/asynctask-threads-never-die-android).

徒留西风 2024-09-22 21:17:02

您可以尝试将启动画面设置为您的活动的主题

You can try setting the Splashscreen as a theme to your activity

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文