来点前奏说明
App启动方式:
1、黑白屏产生原因:
1.找到style的AppTheme(我的是这个,使用默认的)
2.点父样式,一直点父样式,直到 Platform.AppCompat.Light 在这个里面有个属性
<item name="android:windowBackground">@color/background_material_light</item>
3.一直点击颜色直到找到
<color name="material_grey_50">#fffafafa</color>
4.这个颜色就是白色
Application的onCreate方法中睡三秒
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
主题添加明显的颜色
<item name="android:windowBackground">@color/colorPrimary</item>
2、一般做法(伪优化)
<item name="android:windowBackground">@drawable/bg</item>
<item name="android:windowIsTranslucent">true</item>
<!--背景设置为空-->
<item name="android:windowBackground">@null</item>
<!--不加载-->
<item name="android:windowDisablePreview">true</item>
1.在style.xml中增加一个主题
<style name="AppTheme.Launcher" parent="AppTheme">
<!--背景设置为空-->
<item name="android:windowBackground">@null</item>
<!--不加载-->
<item name="android:windowDisablePreview">true</item>
</style>
2.在清单文件找到主页面,设置上面的主题
android:theme="@style/AppTheme.Launcher"
3.在主页面的onCreate方法内
setTheme(R.style.AppTheme_Launcher);
3、深层优化做法
3.1.1.Application的onCreate方法中刚开始增加
File file = new File(Environment.getExternalStorageDirectory(), "app.trace");
Debug.startMethodTracing(file.getAbsolutePath());
3.1.2.结束的时候增加
Debug.stopMethodTracing();
3.1.3.找到app.trace我是链接电脑就在根目录,拖进AS中分析 选择Top Down
对于耗时操作,分析是否能否懒加载延时加载,initX5Environment这个方法我放在延时加载,看下效果。一点点分析,这个一定要耐心一点分析,分析之后修改测试。
FAQ
问题和答疑