[英]Android splash screen is white in the beginning?
當我啟動我的應用程序時,我會在啟動閃屏之前看到白屏幾秒鍾。
我想知道我的應用程序的大小是否會影響它(它是17.7MB)。 或者是因為我的測試設備是舊的(HTC Desire HD)並且有太多數據被破壞了?
或者這是正常的行為? 或者問題可能在我的代碼中,這是在...
部分清單:
<activity android:name=".SplashView"
android:noHistory="true"
android:screenOrientation="portrait"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation" >
<intent-filter >
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
飛濺活動:
public class SplashView extends SherlockActivity {
private final int SPLASH_DISPLAY_LENGHT = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.splash_view);
try {
RefreshRatingsTask urt = new RefreshRatingsTask();
urt.execute();
} catch (Exception e) {
// ignore
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent mainIntent = new Intent(SplashView.this,
MainActivity.class);
SplashView.this.startActivity(mainIntent);
SplashView.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
}
}
謝謝
Android使用您的初始Activity的Theme來顯示虛擬Activity,同時將應用程序加載到內存中。
使您的應用程序更小將有助於減少等待的長度,並使用主題設置啟動屏幕的樣式將使其不那么明顯。
Cyril Mottier撰寫的這篇博文有更多細節。
RefreshRatingsTask urt = new RefreshRatingsTask();
urt.execute();
這個asynctask似乎是罪魁禍首。 它的操作可能需要一些時間,因此閃屏不會馬上出現。 注釋並再次檢查。
此外,在飛濺活動中做重物也不是一個好習慣。 為它創建服務並在后台執行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.