Qt for Android 启动短暂的黑屏或白屏问题如何解决?

解决方法一:

使用透明主题
点击项目 -> 在 构建设置 里面找到 Build Android APK 栏目,点击 create templates 创建一个 AndroidManifest.xml

<?xml version="1.0"?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
    <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --">
        <activity
            android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
            android:name="org.qtproject.qt5.android.bindings.QtActivity"
            android:label="-- %%INSERT_APP_NAME%% --"
            android:screenOrientation="unspecified"
            android:launchMode="singleTop"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
                        <!--  添加上面一条即可,只是把黑屏设置成透明的而已,启动还是会慢  -->
                        <!--  @android:style/Theme.Translucent   -->
            <!-- @android:style/Theme.Translucent.NoTitleBar   -->
            <!-- @android:style/Theme.Translucent.NoTitleBar.Fullscreen   -->
            >

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            <!-- Application arguments -->
            <!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
            <!-- Application arguments -->

            <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
            <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
            <meta-data android:name="android.app.repository" android:value="default"/>
            <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
            <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
            <!-- Deploy Qt libs as part of package -->
            <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
            <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
            <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
            <!-- Run with local libs -->
            <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
            <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
            <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
            <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
            <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
            <!--  Messages maps -->
            <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
            <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
            <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
            <!--  Messages maps -->

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

            <!-- Background running -->
            <!-- Warning: changing this value to true may cause unexpected crashes if the
                          application still try to draw after
                          "applicationStateChanged(Qt::ApplicationSuspended)"
                          signal is sent! -->
            <meta-data android:name="android.app.background_running" android:value="false"/>
            <!-- Background running -->

            <!-- auto screen scale factor -->
            <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
            <!-- auto screen scale factor -->

            <!-- extract android style -->
            <!-- available android:values :
                * full - useful QWidget & Quick Controls 1 apps
                * minimal - useful for Quick Controls 2 apps, it is much faster than "full"
                * none - useful for apps that don't use any of the above Qt modules
                -->
            <meta-data android:name="android.app.extract_android_style" android:value="full"/>
            <!-- extract android style -->
    </activity>

    <!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->

    </application>

    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
    <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>

    <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
         Remove the comment if you do not require these default permissions. -->
    <!-- %%INSERT_PERMISSIONS -->

    <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
         Remove the comment if you do not require these default features. -->
    <!-- %%INSERT_FEATURES -->

</manifest>
解决方法二:

使用图片替换主题

在res/values文件目录下新建一个 style.xml 文件,文件内容如下
<?xml version='1.0' encoding='utf-8'?>
<resources>
<style name="Theme.AppStartLoad" parent="android:Theme">
    <item name="android:windowBackground">@drawable/logo</item>
        <!-- @drawable/logo 确保 android\res\drawable-hdpi\logo.png 存在 -->
    <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">
<activity  android:theme="@style/Theme.AppStartLoad">

            <!-- Splash screen -->
            <!-- <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/> -->
            <!-- <meta-data android:name="android.app.splash_screen_sticky" android:value="true"/> -->
            <!-- Splash screen -->
                        //这上面的是添加启动图片
解决方案三
https://falsinsoft.blogspot.com/2017/07/qml-show-android-native-splash-screen.html

原文地址:https://www.cnblogs.com/cheungxiongwei/p/8661211.html

时间: 2024-08-17 11:55:22

Qt for Android 启动短暂的黑屏或白屏问题如何解决?的相关文章

Android 跨进程启动Activity黑屏(白屏)的三种解决方案

原文链接:http://www.cnblogs.com/feidu/p/8057012.html 当Android跨进程启动Activity时,过程界面很黑屏(白屏)短暂时间(几百毫秒?).当然从桌面Lunacher启动一个App时也会出现相同情况,那是因为App冷启动也属于跨进程启动Activity.为什么没会出现这种情况呢?真正元凶就是Android创建进程需要准备很多资源,它是一个耗时的操作. 黑屏(白屏)原因 当A进程启动B进程中的一个Activity时,Android系统会先有zygo

Android 启动APP时黑屏白屏的三个解决方案

你会很奇怪,为什么有些app启动时,会出现一会儿的黑屏或者白屏才进入Activity的界面显示,但是有些app却不会如QQ手机端,的确这里要做处理一下.这里先了解一下为什么会出现这样的现象,其实很简单,简历一个简单的例子就可以理解了. 其实,黑屏或者白屏这里并不是不正常,而是还没加载到布局文件,就已经显示了window窗口背景,黑屏白屏就是window窗口背景.代码如下,可以自己写个小demo就理解了. @Override protected void onCreate(Bundle saved

Android 启动APP时黑屏白屏的三个解决方案(转载)

你会很奇怪,为什么有些app启动时,会出现一会儿的黑屏或者白屏才进入Activity的界面显示,但是有些app却不会如QQ手机端,的确这里要做处理一下.这里先了解一下为什么会出现这样的现象,其实很简单,简历一个简单的例子就可以理解了. 其实,黑屏或者白屏这里并不是不正常,而是还没加载到布局文件,就已经显示了window窗口背景,黑屏白屏就是window窗口背景.代码如下,可以自己写个小demo就理解了. 1 2 3 4 5 6 7 8 9 10 11 12 @Override protected

Android启动时闪一下黑屏或者白屏

1.设定主题,此主题为透明的,加入到res/values/styles.xml中: <style name="Theme.AppStartLoadTranslucent" parent="android:Theme"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowNoTitle&qu

Activity跳转黑屏,闪屏,白屏解决

Activity里添加跳转动画 overridePendingTransition(R.anim.right_in, R.anim.left_out); sytles文件里添加 <style name="Theme" parent="android:Theme"> <item name="android:windowBackground">@android:color/transparent</item> &l

首屏,白屏时间如何计算??

做移动web页面,受移动网络网速和终端性能影响,我们经常要关注首屏内容展示时间(以下简称首屏时间)这个指标,它衡量着我们的页面是否能在用户耐心消磨完之前展示出来,很大程度影响着用户的使用满意度. 怎么获取首屏时间呢? 我们经常要先问自己:页面是怎么加载数据? A:加载完静态资源后通过ajax请求去后台获取数据,数据回来后渲染内容 在每个点打上一个时间戳,首屏时间 = 点8 – 点1: B:使用后台直出,返回的html已经带上内容了 此时首屏时间 = 点4 – 点1. 注:1. 打了这么多个点,是

Android项目启动时短暂的黑屏白屏处理

刚从csdn转战51,这是在51写的第一篇博客 那么我们来谈谈这样一个问题.当你的项目需要用的欢迎界面有时候会出现短暂的黑屏或白屏,这样用户体验就不好了,所以今天教教大家如何处理这种问题. 其实,黑屏或者白屏是因为程序还没有加载布局就已经显示window窗口背景,而黑屏或者白屏就是window窗口背景.那么如何处理呢?看下面... public class LoadingActivity extends AppCompatActivity {          @Override       p

Android启动黑屏白屏解决方案

在App的Splash页面启动时会出现短暂的黑屏或者白屏,会带来很不好的用户体验,究其原因是因为资源还未加载完成而导致的黑屏或白屏,而我们所看到的黑白屏其实就是顶层Window,下面总结两种解决方案. **设置Window层的界面为我们的Splash界面. <!--防止启动时黑屏,添加window图片--> <style name="Theme.AppStartLoad" parent="android:Theme"> <item na

解决android 启动白屏问题

Android 启动APP时黑屏白屏的三个解决方案 http://www.cnblogs.com/liqw/p/4263418.html android:windowSoftInputMode属性使用 http://www.blogjava.net/zhip/archive/2011/02/14/344258.html