您的位置:首页 > 移动开发 > Android开发

Qt for Android 程序启动黑屏情况处理

2016-07-03 21:30 477 查看
Qt for Android的坑还是蛮多的,启动黑屏问题就是一个,有人说设置启动界面SplashScreen就可以了,进入SplashScreen之前,应用仍然会黑屏,如下图




第二张才是启动界面的图片,在启动界面之前会有第一张图片,带给用户的体验不太好。

我们在工程目录下添加一个styles.xml文件,如下图



styles.xml内容如下:

<resources>
<style name="Theme.AppStartLoad" parent="android:Theme">
<item name="android:windowBackground">@drawable/logo</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>


然后在AndroidManifest.xml中的activity中加上android:theme="@style/Theme.AppStartLoad",如下图



这样改完之后,运行程序发现黑屏到启动界面之后了,也就是启动界面到主界面之间还有黑屏,需要修改styles.xml,内容如下:

<resources>
<style name="Theme.AppStartLoad" parent="android:Theme">
<item name="android:windowBackground">@drawable/logo</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Theme.AppStartLoadTranslucent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>


在在AndroidManifest.xml中的application中加上android:theme = "@style/Theme.AppStartLoadTranslucent",然后添加下面的内容,不然当主界面内容比较多时,依旧会出现黑屏问题。

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


运行程序,黑屏没有了。先启动application是透明的,再启动activity是启动画面。

但是启动界面到主界面还是有一闪的问题,应该是android启动activity之后到qt的widget启动之间出现的黑屏遗留的问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: