Application和Activity中的onCreate都進行了優化,基本沒有耗時操作,但是啟動應用之后還是會閃現一下白色背景,然后才進入Splash頁面,對比了一下QQ、微信、微博等客戶端,點擊之后都是瞬間響應Splash啟動頁,差別在哪里呢。
其實就算你onCreate啥都不做,仍然會閃一下白屏,因為初始化解析界面時需要一定時間,解決方法是自定義Theme。
自定義如下
<style name="AppSplash" parent="android:Theme">
<item name="android:windowBackground">@drawable/ipod_bg</item>
<item name="android:windowNoTitle">true</item>
</style>
配置文件中配置如下
<activity
android:theme="@style/AppSplash"
android:name=".SplashActivity" >
</activity>
啟動頁 調用:
[Activity(Label = "", Theme = "@style/AppSplash", MainLauncher = true)]
public class StartupActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
StartActivity(typeof(LoginActivity));
OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight);
// Create your application here
}
}
這樣一來,點擊應用圖標之后會馬上有響應,出現設置的背景圖片,跟QQ、微信效果一樣。
