android app 优化启动体验, 不闪白屏并且快速展示 splash
2018-01-11 11:58
369 查看
本文首发在我的个人博客: http://www.geekqian.com/post/9d4eac9b.html
转载请注明出处
要优化 app 的启动体验, 首先在清单文件中第一个启动的 SplashActivity 使用了 theme 的方式.
在 style.xml 文件中定义
注意 @drawable/splash 可以是一张图片, 也可以是定义在 drawable 文件夹中的一个 splash.xml 文件.
我这里使用的是 xml 文件的方式.
当时好像是出现了一些问题才这么写. 具体啥问题我想不起来了, 反正这样没毛病.. 哈
另外接入 bugly 后发现了这里报了一个 XmlPullParserException 的问题, 查了一下应该是之前这个 layer-list 的 item 中定义了 @drawable/splash 这种方式导致的, 之前 splash 图片的名字就叫 splash , 导致跟 splash.xml 冲突. 所以改为了 splash_default就搞定了.
转载请注明出处
要优化 app 的启动体验, 首先在清单文件中第一个启动的 SplashActivity 使用了 theme 的方式.
<activity android:name="com.ingdan.xxx.ui.activity.SplashActivity" android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
在 style.xml 文件中定义
<style name="SplashTheme" parent="AppTheme"> <item name="android:windowBackground">@drawable/splash</item> <item name="android:windowFullscreen">true</item> </style>
注意 @drawable/splash 可以是一张图片, 也可以是定义在 drawable 文件夹中的一个 splash.xml 文件.
我这里使用的是 xml 文件的方式.
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@color/colorWhite"/> <item> <bitmap android:src="@drawable/splash_default" android:gravity="center" /> </item> </layer-list>
当时好像是出现了一些问题才这么写. 具体啥问题我想不起来了, 反正这样没毛病.. 哈
另外接入 bugly 后发现了这里报了一个 XmlPullParserException 的问题, 查了一下应该是之前这个 layer-list 的 item 中定义了 @drawable/splash 这种方式导致的, 之前 splash 图片的名字就叫 splash , 导致跟 splash.xml 冲突. 所以改为了 splash_default就搞定了.
相关文章推荐
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- Android 启动APP时会出现黑屏白屏(提高 Splash页面的启动速度)
- Android开发之提高应用启动速度splash页面瞬间响应 避免APP启动闪白屏
- Android性能优化之提高App启动速度和Splash页面设计
- Android app启动白屏优化
- android提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- android AppCompat, splash启动白屏(黑屏)全屏,去掉状态栏,以及splash与虚拟按键遮挡
- android设置启动splash图片(消除启动白屏)不使用Appcompat主题设置的方法
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- Android性能优化之APP启动白屏
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- Android 编程下通过 Theme 和 Style 避免 APP 启动闪黑屏或者白屏,快速启动
- Android App优化之提升你的App启动速度之实例挑战
- Android App应用启动分析与优化
- Android App 启动页(Splash)黑/白闪屏现象
- Android开发之解决APP启动白屏或者黑屏闪现的问题