Android-避免App启动黑白屏闪现的2种方式

App每次启动程序都会闪一下黑屏或白屏(取决于使用的全局样式),因为启动Activity的时候,需要执行完onCreate和onResume才会显示界面。也就是说需要处理一些数据后,才会显示,就算onCreate方法里什么不做,仍然会闪一下黑屏,因为初始化解析界面时需要一定时间。

1、自定义Theme

<style name="Theme.AppStartLoad" parent="android:Theme">    
    <item name="android:windowBackground">@drawable/ic_splash</item>    
    <item name="android:windowNoTitle">true</item>    
</style> 

2、设置透明Theme

<style name="Theme.AppStartLoadTranslucent" parent="android:Theme">    
    <item name="android:windowIsTranslucent">true</item>   
    <item name="android:windowNoTitle">true</item>    
</style>