智者不为愚者谋,勇者不为怯者死。这篇文章主要讲述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=https://www.songbingjia.com/android/"
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>
解决方法二:【Qt for Android 启动短暂的黑屏或白屏问题如何解决()】使用图片替换主题
在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 中应用上面定义的两个主题,添加的位置如下
<
applicationandroid:theme = "
@style/Theme.AppStartLoadTranslucent"
>
<
activityandroid: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=https://www.songbingjia.com/android/"
true"
/>
-->
<
!-- Splash screen -->
//这上面的是添加启动图片
解决方案三
https://falsinsoft.blogspot.com/2017/07/qml-show-android-native-splash-screen.html
推荐阅读
- Lintcode363 Trapping Rain Water solution 题解
- Spring使用MappingJackson2MessageConverter发送接收ActiveMQ消息
- pycharm运行Django发生AppRegistryNotReady: Apps aren't loaded yet.
- Lintcode364 Trapping Rain Water II solution 题解
- Android TextView数字增长动画效果
- 安卓的权限大全和动态使用安卓权限
- android——No matching client found for package错误处理
- android——Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER 解决方案
- Android Surfaceflinger服务 ----- BufferQueue分析