我想在應用程序啓動之前顯示徽標幾秒鐘,並且菜單可見。我也想在消失時使用一些。我應該創建一個新的活動嗎?我可以在佈局中設置它嗎?在應用程序啓動時顯示徽標幾秒鐘
9
A
回答
15
爲啓動屏幕定義一個佈局,其中將包含您的徽標,然後將此代碼添加到您的a ctivity:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
//display the logo during 5 seconds,
new CountDownTimer(5000,1000){
@Override
public void onTick(long millisUntilFinished){}
@Override
public void onFinish(){
//set the new Content of your activity
YourActivity.this.setContentView(R.layout.main);
}
}.start();
}
+0
+,不知道CountDownTimer好戲 –
2
您可以使用獲取setVisibility(Visibility.GONE)的圖像視圖;或者某種程度上,或者你可以編寫一段時間結束後彈出並退出的活動。那是你的個人喜好...
0
爲什麼?用戶不喜歡等待。但是,如果你需要等待,因爲你加載一些數據,您可以:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
/* Do some work in a new thread, calling setContentView at the end with your view */
}
0
0
package com.karan.android.video;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class splash extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread splashThread = new Thread()
{
@Override
public void run()
{
try {
int waited = 0;
while (waited < 3000)
{
sleep(100);
waited += 100;
}
} catch (InterruptedException e)
{
// do nothing
} finally
{
finish();
Intent i = new Intent(splash.this,video.class);
startActivity(i);
}
}
};
splashThread.start();
}
}
Xml file:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/buff"
android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<TextView
android:textSize="40dp"
android:textColor="#CCFF00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Buffering..."
/>
</FrameLayout>
0
延遲執行可以simplier方式實現:
new Handler().postDelayed(new Runnable() {
// ... Hide splash image and show the real UI
}, 3000)
而且Android標準android.widget.ViewSwitcher
類是這種東西非常有用的。
相關問題
- 1. Android當應用程序啓動時顯示白色屏幕幾秒鐘?
- 2. 應用程序在設備啓動前幾秒鐘凍結
- 3. UWP應用程序在啓動後幾秒鐘內崩潰
- 4. NSURLErrorDomain代碼= -1004幾秒鐘後,應用程序啓動
- 5. 幾秒鐘後應用程序崩潰
- 6. 幾秒鐘後應用程序崩潰
- 7. 顯示圖像幾秒鐘
- 8. 幾秒鐘後自動顯示div javascript
- 9. CakePHP應用程序會在幾秒鐘內自動註銷
- 10. 通過Testflight在iOS 9.2.1上啓動後,應用程序崩潰了幾秒鐘
- 11. PhoneGap徽標在啓動IOS應用程序時被刪除
- 12. 在Android中顯示ProgressBar幾秒鐘
- 13. Android - 如何在行動欄中顯示應用程序徽標
- 14. 啓動期間黑屏幾秒鐘
- 15. 號選擇器啓動幾秒鐘
- 16. Openshift V3:啓動SpringBoot/MySQL的應用程序後,該應用程序在幾秒鐘
- 17. 當iOS應用程序啓動時移除Cordova徽標
- 18. 幾秒鐘後顯示警告視圖
- 19. 顯示和刪除圖像幾秒鐘
- 20. 顯示CCLabel觸摸幾秒鐘
- 21. 如何暫停顯示器幾秒鐘?
- 22. 用命令行啓動matlab需要幾秒鐘的時間
- 23. 線在Windows Store應用程序幾秒鐘後消失
- 24. 幾秒鐘後在Windows Mobile應用程序上關閉MessageBox(C#)
- 25. 如何使用Google應用程序腳本在幾秒鐘後隱藏標籤?
- 26. 幾秒鐘後重新啓用按鈕
- 27. 設置鬧鐘在時鐘應用程序中顯示
- 28. Iphone桌面查看時間顯示在幾秒鐘內
- 29. 在調用應用程序之前,應用程序顯示但響應時間不超過5秒鐘WillEnterForeground
- 30. 每次啓動Android應用程序時顯示啓動畫面
這可能會幫助你:http://www.barebonescoder.com/2010/04/a-simple-android-splash-screen/ –
像一個閃屏? [Here](http://www.droidnova.com/how-to-create-a-splash-screen,561.html)就是一個例子。 –
還檢查出http://www.gadgetsaint.com/android/create-video-splash-screen-android/ – ASP