我有空的Qt / QML android应用程序,并且我试图显示初始屏幕。
如果不执行启动屏幕,则会显示以下屏幕:
现在,我将按照此初始屏幕示例,将初始屏幕添加到android清单文件中。这是我得到的结果:
我的问题是,是否可以避免屏幕编号1?我希望启动应用程序时立即显示启动屏幕,而不是屏幕1。任何建议都欢迎。提前致谢。
I think I found a solution for this problem thanks to this post.
Author of that post, for splash screens in Qt/QML android app wrote:
Basically, you could ignore any solution by C++/QML code only. Because they are started late.
I would like to add that, when author said "they are started late", I think it is because all of your Qt/QML android app is compiled at the end like .so (shared library). So when your app start, what happens behind is:
Now the solution to display splash screen(Steps from the post above):
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"/>
现在其余的都在您的main.qml文件中。在开始时将Window / ApplicationWindow元素设置为不可见(如我所见,它将保留初始屏幕),在第一页中使用Loader,并在加载时将Window / ApplicationWIndow设置为true。这是我的示例:
加载程序{id:异步加载程序:true anchors.fill:父源组件:MainScreen {宽度:root.width高度:root.height
Component.onCompleted:
{
root.isReady = true
}
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句