Android Development Learning Note: The simplest way to implement the APP Welcome screen

Source: Internet
Author: User

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">
7     
8
9 </LinearLayout>

Write in the corresponding activity Welcome.java:

01 importjava.util.Timer;
02 importjava.util.TimerTask;
03
04 importandroid.app.Activity;
05 importandroid.content.Intent;
06 importandroid.os.Bundle;
07
08 publicclass Welcome extendsActivity {
09
10     @Override
11     protectedvoidonCreate(Bundle savedInstanceState) {
12         super.onCreate(savedInstanceState);
13         setContentView(R.layout.welcome);
14         //通过一个时间控制函数Timer,在实现一个活动与另一个活动的跳转。
15      newTimer().schedule(newTimerTask() {
16    @Override
17    publicvoidrun() {
18     startActivity(newIntent(Welcome.this,MainActivity.class));
19     finish();
20     
21    }
22   }, 3000);//这里停留时间为1000=1s。
23  }
24
25 }

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:

1      <activity
2             android:name="com.example.welcome.Welcome"
3             android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
4              <intent-filter>
5                 <action android:name="android.intent.action.MAIN"/>
6
7                 <category android:name="android.intent.category.LAUNCHER"/>
8             </intent-filter>
9           </activity>

Then delete the following part of the activity:

1   <intent-filter>
2                 <action android:name="android.intent.action.MAIN"/>
3
4                 <category android:name="android.intent.category.LAUNCHER"/>
5             </intent-filter>

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.