We often use the welcome interface when we develop the app, here we recommend a simple, fast, easy to fit with the existing project a method, hope to help everyone.
First look at the effect:
You need to create an additional welcome.xml layout, just replace the background with the imported image, the code is as follows:
1 |
<?xml version="1.0"encoding="utf-8"?> |
2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 |
android:layout_width="match_parent" |
4 |
android:layout_height="match_parent" |
5 |
android:orientation="vertical" |
6 |
android:background="@drawable/welcome"> |
Write in the corresponding activity Welcome.java:
01 |
importjava.util.Timer; |
02 |
importjava.util.TimerTask; |
04 |
importandroid.app.Activity; |
05 |
importandroid.content.Intent; |
06 |
importandroid.os.Bundle; |
08 |
publicclass Welcome extendsActivity { |
11 |
protectedvoidonCreate(Bundle savedInstanceState) { |
12 |
super.onCreate(savedInstanceState); |
13 |
setContentView(R.layout.welcome); |
14 |
//通过一个时间控制函数Timer,在实现一个活动与另一个活动的跳转。 |
15 |
newTimer().schedule(newTimerTask() { |
18 |
startActivity(newIntent(Welcome.this,MainActivity.class)); |
22 |
}, 3000);//这里停留时间为1000=1s。 |
Note: Here is the most important point, add the first activity (be sure to put it in the first position) below the <application in Androidmanifest.xml and the code is as follows:
2 |
android:name="com.example.welcome.Welcome" |
3 |
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> |
5 |
<action android:name="android.intent.action.MAIN"/> |
7 |
<category android:name="android.intent.category.LAUNCHER"/> |
Then delete the following part of the activity:
2 |
<action android:name="android.intent.action.MAIN"/> |
4 |
<category android:name="android.intent.category.LAUNCHER"/> |
Here is a demo of small wood:
http://download.csdn.net/detail/u013671350/7674525
Android Development Learning Note: The simplest way to implement the APP Welcome screen