如何使一个启动画面? [英] How do I make a splash screen?
本文介绍了如何使一个启动画面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使我的应用程序看起来更专业,所以我决定,我想作一个启动画面。
I wanted to make my app look more professional, so I decided that I wanted to make a splash screen.
我将如何创建它,然后实现它?
How would I create it and then implement it?
推荐答案
如何:简单spash屏幕
这答案告诉您如何只显示启动画面的时间固定金额,当你的应用程序启动的如品牌的原因。
This answers shows you how to just display a splash screen for a fixed amount of time when your app starts for e.g. branding reasons.
首先,您需要定义spash屏幕在你的 layout.xml
文件
First you need to define the spash screen in your layout.xml
file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/splashscreen" android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/splash"
android:layout_gravity="center"/>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, splash"/>
</LinearLayout>
和你的活动:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class Splash extends Activity {
/** Duration of wait **/
private final int SPLASH_DISPLAY_LENGTH = 1000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.splashscreen);
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(Splash.this,Menu.class);
Splash.this.startActivity(mainIntent);
Splash.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
}
这就是所有;)
Thats all ;)
这篇关于如何使一个启动画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文