简体   繁体   English

如何在Android的Qt5.2中创建启动画面?

[英]How can I create splash screen in Qt5.2 on Android?

I have created Android application using Qt5.2. 我已经使用Qt5.2创建了Android应用程序。 It takes a long time to start my application. 启动我的应用程序需要很长时间。 Qt5 draws black screen by default during application start up. Qt5默认在应用程序启动期间绘制黑屏。

I want to display company's logo during application start up. 我想在启动应用程序时显示公司徽标。 How can I do it? 我该怎么做?

I have found code in QtActivity.java for loading splash screen if it presents. 我在QtActivity.java中找到了用于加载启动屏幕(如果显示)的代码。 There is a reference in AndroidManifest.xml to splash screen layout. AndroidManifest.xml中有一个参考来启动屏幕布局。 I have tried to create splash.xml in res/layout directory but it doesn't work. 我试图在res / layout目录中创建splash.xml,但是它不起作用。

Thank you! 谢谢!

There's a bug with the splash screen, and here's the ticket for it: qt-bugreports 启动画面中有一个错误,这是它的门票: qt-bugreports

If you follow this link you will find a comment ( link ), which shows a way to display splash screen. 如果您单击此链接,您将找到一个注释( 链接 ),该注释显示了一种显示初始屏幕的方法。 (I haven't tested it) (我还没有测试)

See this article for detailed steps to create a splash screen that will show immediately: 请参阅本文,以了解创建初始屏幕并立即显示的详细步骤:

Complete Guide to Making a Splash Screen for your QML Android Application — Medium 为您的QML Android应用程序制作启动画面的完整指南-中

One way 1 to show a splash screen is to edit the android/AndroidManifest.xml . 显示初始屏幕的一种方式1是编辑android/AndroidManifest.xml Be aware that the Android Manifest editor doesn't provide a GUI to these options 2 , and so it is necessary to use a text editor. 请注意,Android Manifest编辑器没有为这些选项2提供GUI,因此有必要使用文本编辑器。 The default AndroidManifest.xml has a line dealing with splash screens, but it is commented out: 默认的AndroidManifest.xml有一行处理初始屏幕,但已注释掉:

<!-- Splash screen -->
<!--
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
-->
<!-- Splash screen -->

Uncomment it, and once you've added application icons to your project via QtCreator's Android Manifest Editor then in your android directory there will be drawable-* sub-directories. 取消注释,然后通过QtCreator的Android清单编辑器将应用程序图标添加到项目中后,在android目录中将出现drawable-*子目录。 Add your splash images there. 在其中添加您的启动图像。 The filename should match what comes after @drawable/ in the resource attribute. 文件名应与资源属性中@drawable/之后的文件名匹配。 Do not specify the file extension in the XML. 不要在XML中指定文件扩展名。

Be sure that you add your splash page images to the project directory and not the build directory because the build directory's resources are deleted on each new build. 确保将初始页面图像添加到项目目录而不是构建目录中,因为在每个新构建中都会删除该构建目录的资源。

  1. Tested in Qt 5.6 在Qt 5.6中测试
  2. In QtCreator 3.6 在QtCreator 3.6中

Thanks to Larpon's post on Qt's forum for the clues. 感谢Larpon 在Qt论坛上发布的线索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM