这篇文章主要介绍了完美解决Android App启动页有白屏闪过的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
应用启动的时候有短暂的白屏,如图:
可以通过设置theme的方式来解决
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Transparent">
<item name="android:windowIsTranslucent">true</item>
<item name="windowNoTitle">true</item>
</style>
在AndroidManifest中使用 AppTheme.Transparent
<activity android:name=".MainActivity"
android:theme="@style/AppTheme.Transparent"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
然后重新运行程序安装。
补充知识:解决Android启动页白屏及图片拉伸的问题
【Android小知识】
为了解决Android冷启动延迟、白屏等问题,往往会将启动图片设置到styles.xml文件中去,但是直接在style文件中引用图片的话很大可能会造成图片拉伸和变形,所以建议将图片配置到xml中去,最后在style文件中引入xml就可以了,如下代码所示:
style.xml
<style name="SplashActivityThemes" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/bg_splash</item>
<item name="android:windowFullscreen">true</item>
</style>
bg_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<solid android:color="#FFFFFF"/>
</shape>
</item>
<item
android:bottom="50dp">
<bitmap
android:gravity="bottom|center_horizontal"
android:src="QG1pcG1hcC9pY29uX3dlbGNvbWU="/>
</item>
</layer-list>
以上这篇完美解决Android App启动页有白屏闪过的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程学习网。
沃梦达教程
本文标题为:完美解决Android App启动页有白屏闪过的问题
猜你喜欢
- iOS 对当前webView进行截屏的方法 2023-03-01
- Android实现轮询的三种方式 2023-02-17
- Android studio实现动态背景页面 2023-05-23
- Android实现监听音量的变化 2023-03-30
- 详解flutter engine 那些没被释放的东西 2022-12-04
- SurfaceView播放视频发送弹幕并实现滚动歌词 2023-01-02
- 最好用的ios数据恢复软件:PhoneRescue for Mac 2023-09-14
- Flutter实现底部和顶部导航栏 2022-08-31
- Android MaterialButton使用实例详解(告别shape、selector) 2023-06-16
- 作为iOS开发,这道面试题你能答出来,说明你基础很OK! 2023-09-14
