我有一个空的 Qt/QML Android 应用,我想显示启动屏幕。
没有 启动屏幕实现,这些屏幕会被显示:
现在我正在按照此例子添加了启动屏幕到Android清单文件中。这是我得到的结果:
我的问题是,有没有可能避免屏幕1?我希望启动应用程序时立即显示启动屏幕。欢迎任何建议。提前致谢。
我有一个空的 Qt/QML Android 应用,我想显示启动屏幕。
没有 启动屏幕实现,这些屏幕会被显示:
现在我正在按照此例子添加了启动屏幕到Android清单文件中。这是我得到的结果:
我的问题是,有没有可能避免屏幕1?我希望启动应用程序时立即显示启动屏幕。欢迎任何建议。提前致谢。
感谢这篇文章,我认为我找到了解决这个问题的方法。
该文章作者针对 Qt/QML android 应用程序中闪屏界面的编写,写道:
基本上,你可以忽略任何仅使用 C++/QML 代码的解决方案。因为它们启动的太晚了。
我想补充一下,当作者说“它们启动太晚了”时,我认为这是因为所有的Qt/QML android应用程序在最后像.so(共享库)一样编译。所以当您的应用程序启动时,背后发生的事情是:
现在解决方案以显示闪屏界面(详见上文文章):
Create template from QtCreator for your android app if you don't have created yet.
Create splash.xml inside android/res/drawable, like this
Create custom theme, apptheme.xml inside android/res/values, like this
Add this line in your activity tag in AndroidManifest.xmnl
android:theme="@style/AppTheme"
Also this line in AndroidManifest.xml, inside activity tag:
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
Now the rest is in your main.qml file. Set your Window/ApplicationWindow element as invisible at beginning(as I saw this will hold the splash screen), use Loader for your first page, and when its loaded, set the Window/ApplicationWIndow visible to true. This is my example:
Loader
{
id: loader
asynchronous: true
anchors.fill: parent
sourceComponent: MainScreen
{
width: root.width
height: root.height
Component.onCompleted:
{
root.isReady = true
}
}
}