2011-12-08 60 views
0

在iOS上,您爲應用加載時創建加載屏幕,Android中是否有類似的東西。當我的應用程序加載時,我會看到一個黑屏,直到它打開。Android中的應用加載屏幕

+1

你問如何創建一個PAG e在資源加載時顯示,或者如何操作設備上第一個屏幕的顯示方式? – Codeman

回答

2

我絕不是一個iOS的專家,但如果你指的是閃屏,你可以做到以下幾點:

創建它的意圖過濾器類是在設置爲LAUNCHER的活動清單...說你怎麼稱呼它飛濺:

<activity 
     android:label="@string/app_name" 
     android:name=".Splash" > 
     <intent-filter > 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
</activity> 

然後在新的活動onCreate執行postDelay開始一個新的意圖:

new Handler().postDelayed(new Runnable() { 
     public void run() { 
      Intent intent = new Intent(); 
      intent.setClass(Splash.this, MyMainActivity.class); 
      Splash.this.startActivity(intent); 
      Splash.this.finish(); 
     } 
    }, 3000); // splash will show for 3 seconds 
+0

這不是問題的答案,它是一個替代方案,http://cyrilmottier.com/2012/05/03/splash-screens-are-evil-dont-use-them/ –

0

只需讓您的主(啓動)屏幕成爲ImageView(或任何您想要的啓動屏幕),然後致電StartActivity()開始您的實際主屏幕。

0

您可以在動畫圖像上顯示具有自定義視圖的活動(使用LayoutInflater進行膨脹,並使用Animation對其進行動畫製作)。多數民衆贊成我是如何做到的。