在應用程序中經常用到啓動畫面,會啓動一個後臺線程爲主程序的運行準備資源。
Android要實現啓動畫面可以這樣做:
這是splash.xml佈局文件的代碼[code]<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<ImageView android:layout_height="fill_parent" android:layout_width="fill_parent" android:scaleType="fitCenter" android:src="@drawable/splash"></ImageView>
</LinearLayout>[/code]
放一個ImageView加載啓動畫面圖片
SplashActivity作爲主視圖啓動/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Handler x = new Handler();
x.postDelayed(new splashhandler(), 2000);
}
class splashhandler implements Runnable{
public void run() {
startActivity(new Intent(getApplication(),MainActivity.class));
SplashActivity.this.finish();
}
}
Android啓動畫面實現
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Android高效安全加載圖片的方法詳解
我爱宋慧乔
2019-02-24 12:42:54
seo行業是否能規範 百度人工干預出招
zuotuitui
2019-02-23 13:37:36
Java IO流學習總結
mada26
2019-02-23 13:06:05
java性能優化筆記(一)概述
kid2412
2019-02-24 13:34:36
Nagios 3.2 監控部署(一)
samplelife
2019-02-23 13:57:35
解決media player內部應用程序錯誤
lhslllj
2019-02-23 13:50:59
用JAAS 和 JSSE 實現 Java 安全性
javatutu
2019-02-23 13:22:24
解決/usr/bin/ld: cannot find -lxxx 問題
ai527518
2019-02-23 13:12:18
Windows編程 第十一回 三問計時器
hu_jiacheng
2019-02-23 13:05:42
Windows編程 第五回 GDI初窺
hu_jiacheng
2019-02-23 13:05:18
”由於應用程序配置不正確,程序未能啓動“的相遇與相識
mapdll
2019-02-23 13:02:47
Linux 三個強大的系統資源監控工具
qq_tang
2019-02-23 13:27:08