啓動過慢
在app啓動的時候,如果發現應用啓動過慢,有可能是下面的情況引起的:
1、依賴了過多的lib
2、app引用的資源導致加載時間過長
3、在啓動頁面的onCreate和onResume執行了耗時比較長的事務
啓動過慢-->導致黑屏
<pre name="code" class="java">//1、設置背景Theme
<style name="Theme.AppStartLoad" parent="android:Theme">
<item name="android:windowBackground">@drawable/ipod_bg</item>
<item name="android:windowNoTitle">true</item>
</style>
//2、設置透明Theme
<style name="Theme.AppStartLoadTranslucent" parent="android:Theme.NoTitleBar.Fullscreen">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
</style>
<activity
android:name=".StartActivity"
<!-- 使用上面定義的樣式 mythou-->
android:theme="@style/Theme.AppStartLoad"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
注意:上面的自定義style,需要使用android:Theme.NoTitleBar.Fullscreen這個主題,否者起始頁面中的圖片會與android:windowBackground的圖片顯示不一致。