Quantcast
Channel: Android*
Viewing all articles
Browse latest Browse all 531

Android 开发学习笔记:最简单的办法实现 APP 欢迎界面

$
0
0

我们在开发APP的时候经常要用到欢迎界面,这里小木推荐给大家一种简单、快速、容易与已有项目契合的一种方法,希望可以帮助到大家。

先看一下截图效果:

 

需要另外建立一个welcome.xml布局,只需要将背景换成导入的图片即可,代码如下:

 

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/welcome">
   

</LinearLayout>

 

在对应的活动Welcome.java中写入:

 

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Welcome extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);
        //通过一个时间控制函数Timer,在实现一个活动与另一个活动的跳转。
     new Timer().schedule(new TimerTask() {
   @Override
   public void run() {
    startActivity(new Intent(Welcome.this,MainActivity.class));
    finish();
    
   }
  }, 3000);//这里停留时间为1000=1s。
 }

}

 
注意:这里是最重要的一点,在AndroidManifest.xml中的<application下面添加第一个Activity(一定要放在第一个位置),代码如下:

 

 

     <activity
            android:name="com.example.welcome.Welcome"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
             <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
          </activity>

 
然后删除下面一个Activity中的部分:

 

 

  <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
 

 

以下是小木写的一个demo:

http://download.csdn.net/detail/u013671350/7674525

 

 

若以上内容帮助到各位,请点个赞或者发个评论,您的鼓励是小木最大的动力!!!

   

  • Andorid
  • 欢迎界面
  • Icon Image: 

  • Android* Development Tools
  • Android*
  • Developers
  • Android*
  • Theme Zone: 

    Android

    Include in RSS: 

    1

    Viewing all articles
    Browse latest Browse all 531


    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>