Android实例-解决启动黑屏问题(Splash XE7后增加了启动界面图片显示)(XE8+小米2)
结果:
1.在启动时马上出现图片界面,但在出现程序界面前会有黑屏,大约有0.2秒左右。
实现:
1.建立2个文件:loading.png和styles.xml:
①其中loading.png是启动时替代黑屏的图片。
②styles.xml是对背景图片的定义,其内容为:
1 <resources> 2 3 <!-- 4 Base application theme, dependent on API level. This theme is replaced 5 by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 6 --> 7 <style name="MyTheme.NoTitleBar.CustomBackground" parent="@android:Theme.Black"> 8 <item name="android:windowBackground">@drawable/loading</item> 9 <item name="android:windowNoTitle">true</item> 10 <item name="android:windowFullscreen">true</item> 11 <item name="android:windowContentOverlay">@null</item> 12 </style> 13 14 <style name="AppBaseTheme" parent="android:Theme.Light"> 15 <!-- 16 Theme customizations available in newer API levels can go in 17 res/values-vXX/styles.xml, while customizations related to 18 backward-compatibility can go here. 19 --> 20 </style> 21 22 <!-- Application theme. --> 23 <style name="AppTheme" parent="AppBaseTheme"> 24 <!-- All customizations that are NOT specific to a particular API-level can go here. --> 25 </style> 26 27 </resources>
2.因为在 Java 下大小写是敏感的,在 styles.xml 定义中“loading ”的这个文件名一定要用小写。
3.文件 styles.xml 和 loading.png 最好放在工程文件所在根目录下。反正不要放在根目录的外面,其下子文件夹倒是可以,文件夹用英文,只是建义,不想找麻烦最好用英文。
4.将建立好的2个文件打包到安装文件中:
①Project ->Deployment->Add Files->选择文件 styles.xml 和 loading.png。
②PlatForm属性都设置为Android。
③RemotePath属性:
styles.xml 的RemotePath为 res\values\
loading.png 的RemotePath为 res\drawable-port\
5.工程缺省配置文件 AndroidManifest.template.xml:
①Ctrl+F9编译工程文件,并生成相关配置文件,打开工程文件所在目录,就可以找到。
②记事本打开AndroidManifest.template.xml文件,查找以下文字:
android:theme="%theme%"
替换为以下文字,注意是替换,不是新增,然后关闭并保存。
android:theme="@style/MyTheme.NoTitleBar.CustomBackground"。
6. 重新编译。
实例二:
相关资料:
https://www.cnblogs.com/hezihang/p/3964909.html 原文章作者地址
Delphi XE7的Splash 功能:
Delphi XE5,XE6,XE7编译的程序在Android下启动会有一段时间黑屏,以前需要用Java扩展Activity增加Splash显示,
现在Delphi XE7增加了Splash Image显示功能了。
步骤:
1.鼠标右键点击工程,选择Options,
2.进入Application分页
3.勾选Include Splash Image
4.选择您的Splash Image文件
5.设置Splash Tile mode和Splash Gravity
Splash Tile Mode
disabled -按图片尺寸大小显示,显示位置有Splash Gravity设置
clamp - 图形边框适应屏幕大小
repeat - 屏幕水平,竖立方向重复填充满Splash Image
mirror - 跟repeat差不多,图片是镜像的。
Gravity 设置比屏幕小的图片在屏幕中的位置,只有当Splash Title Mode为Disable时有效,
参数大家一看便知道什么意思了,我就不提了。
欢迎关注我,一起进步!扫描下方二维码即可加我


【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步