版权声明:本文为HaiyuKing原创文章,转载请注明出处!
StartingWindow 的处理方式:
-------摘自《知乎 救救你的 StartingWindow》
android开发者应该都有这样的体会:开发到一定的阶段,包变得很大了,每次启动APP的时候,总是有白屏一闪而过(白屏的时间和包的大小成正比!)。
-------摘自《Android APP启动白屏优化》
本文讲的是第二种处理方式。
暂无
注意事项:
1、 导入类文件后需要change包名以及重新import R文件路径
2、 Values目录下的文件(strings.xml、dimens.xml、colors.xml等),如果项目中存在,则复制里面的内容,不要整个覆盖
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <!-- 应用启动页(StartingWindow)的theme --> <style name="AppTheme.StartingWindowTheme" parent="AppTheme"> <!-- 可以设置成纯颜色(设置一个和Activity UI相似的背景) --> <!--<item name="android:windowBackground">@color/startingwindow_bgcolor</item>--> <!--也可以设置成一张图片 --> <item name="android:windowBackground">@drawable/startingwindow_bg</item> </style> </resources>
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#3F51B5</color> <color name="colorPrimaryDark">#303F9F</color> <color name="colorAccent">#FF4081</color> <!-- 应用启动页(StartingWindow)的theme的背景色 --> <color name="startingwindow_bgcolor">#00bfff</color> </resources>
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.why.project.androidstartingwindowdemo"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <!--将首页的them设置成自定义的样式--> <activity android:name=".MainActivity" android:theme="@style/AppTheme.StartingWindowTheme"> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest>
无
无
https://github.com/haiyuKing/AndroidStartingWindowDemo
Android APP应用启动页白屏(StartingWindow)优化
原文:https://www.cnblogs.com/whycxb/p/9312914.html